use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class CreateChangeIT method basic.
/**
* Just a basic test. The real functionality is tested by {@link
* com.google.gerrit.acceptance.rest.change.CreateChangeIT}.
*/
@Test
public void basic() throws Exception {
BranchInput branchInput = new BranchInput();
branchInput.ref = "foo";
assertThat(gApi.projects().name(project.get()).branches().get().stream().map(i -> i.ref)).doesNotContain(REFS_HEADS + branchInput.ref);
RestResponse r = adminRestSession.put("/projects/" + project.get() + "/branches/" + branchInput.ref, branchInput);
r.assertCreated();
ChangeInput input = new ChangeInput();
input.branch = "foo";
input.subject = "subject";
RestResponse cr = adminRestSession.post("/projects/" + project.get() + "/create.change", input);
cr.assertCreated();
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class AccountsRestApiBindingsIT method starEndpoints.
@Test
public void starEndpoints() throws Exception {
ChangeInput ci = new ChangeInput(project.get(), "master", "Test change");
String changeId = gApi.changes().create(ci).get().id;
execute(adminRestSession, STAR_ENDPOINTS, "self", changeId);
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class RequestScopeOperationsImplTest method checkSshUser.
private void checkSshUser(Account.Id expected) throws Exception {
// No "gerrit whoami" command, so the simplest way to check who the user is over SSH is to query
// for owner:self.
ChangeInput cin = new ChangeInput();
cin.project = project.get();
cin.branch = "master";
cin.subject = "Test change " + changeCounter.incrementAndGet();
String changeId = gApi.changes().create(cin).get().changeId;
assertThat(gApi.changes().id(changeId).get().owner._accountId).isEqualTo(expected.get());
String queryResults = atrScope.get().getSession().exec("gerrit query owner:self change:" + changeId);
assertWithMessage("Change-Ids in query results:\n%s", queryResults).that(findDistinct(queryResults, "I[0-9a-f]{40}")).containsExactly(changeId);
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byAuthorEmail.
@Test
public void byAuthorEmail() throws Exception {
TestAccount user2 = accountCreator.create("Foo", "user@example.com", "User", /* displayName = */
null);
requestScopeOperations.setApiUser(user2.id());
ChangeInfo info = gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get();
ChangeData cd = changeQueryProvider.get().byLegacyChangeId(Change.Id.tryParse(Integer.toString(info._number)).get()).get(0);
// Match by email works
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^.*@example\\.com\"", SubmitRequirementResult.Status.SATISFIED);
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^user@.*\\.com\"", SubmitRequirementResult.Status.SATISFIED);
// Match by name does not work
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^Foo$\"", SubmitRequirementResult.Status.UNSATISFIED);
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^User$\"", SubmitRequirementResult.Status.UNSATISFIED);
}
use of com.google.gerrit.extensions.common.ChangeInput in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitEmptyCommitPatchSetCanFastForward_emptyCommitNotAllowed.
@Test
@TestProjectInput(rejectEmptyCommit = InheritableBoolean.TRUE)
public void submitEmptyCommitPatchSetCanFastForward_emptyCommitNotAllowed() throws Throwable {
ChangeInput ci = new ChangeInput();
ci.subject = "Empty change";
ci.project = project.get();
ci.branch = "master";
ChangeApi change = gApi.changes().create(ci);
approve(change.id());
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> change.current().submit());
assertThat(thrown).hasMessageThat().contains("Change " + change.get()._number + ": Change could not be merged because the commit is empty. Project policy" + " requires all commits to contain modifications to at least one file.");
}
Aggregations