use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_evaluatedWithInternalUserCredentials.
@Test
public void submitRequirement_evaluatedWithInternalUserCredentials() throws Exception {
GroupInput in = new GroupInput();
in.name = "invisible-group";
in.visibleToAll = false;
in.ownerId = adminGroupUuid().get();
gApi.groups().create(in);
configSubmitRequirement(project, SubmitRequirement.builder().setName("My-Requirement").setApplicabilityExpression(SubmitRequirementExpression.of("ownerin:invisible-group")).setSubmittabilityExpression(SubmitRequirementExpression.create("is:true")).setAllowOverrideInChildProjects(false).build());
requestScopeOperations.setApiUser(user.id());
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
ChangeInfo change = gApi.changes().id(changeId).get();
SubmitRequirementResultInfo srResult = change.submitRequirements.stream().filter(sr -> sr.name.equals("My-Requirement")).collect(MoreCollectors.onlyElement());
assertThat(srResult.status).isEqualTo(Status.NOT_APPLICABLE);
}
use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.
the class GroupsIT method createGroupWithInvalidUuid_BadRequest.
@Test
public void createGroupWithInvalidUuid_BadRequest() throws Exception {
AccountGroup.UUID uuid = AccountGroup.UUID.parse("foo:bar");
GroupInput input = new GroupInput();
input.uuid = uuid.get();
input.name = name("new-group");
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.groups().create(input).get());
assertThat(thrown).hasMessageThat().isEqualTo(String.format("invalid group UUID '%s'", input.uuid));
}
use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.
the class GroupsIT method createGroupWithExistingUuid_Conflict.
@Test
public void createGroupWithExistingUuid_Conflict() throws Exception {
GroupInfo existingGroup = gApi.groups().create(name("new-group")).get();
GroupInput input = new GroupInput();
input.uuid = existingGroup.id;
input.name = name("another-new-group");
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.groups().create(input).get());
assertThat(thrown).hasMessageThat().isEqualTo(String.format("group with UUID '%s' already exists", input.uuid));
}
use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.
the class GroupsIT method createGroupWithUuid.
@Test
public void createGroupWithUuid() throws Exception {
AccountGroup.UUID uuid = AccountGroup.UUID.parse("4eb25d1cca562f53b9356117f33840706a36a349");
GroupInput input = new GroupInput();
input.uuid = uuid.get();
input.name = name("new-group");
GroupInfo info = gApi.groups().create(input).get();
assertThat(info.name).isEqualTo(input.name);
assertThat(info.id).isEqualTo(input.uuid);
}
use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.
the class GroupsIT method cachedGroupsForMemberAreUpdatedOnGroupCreation.
@Test
public void cachedGroupsForMemberAreUpdatedOnGroupCreation() throws Exception {
Account.Id accountId = accountOperations.newAccount().create();
// Fill the cache for the observed account.
groupIncludeCache.getGroupsWithMember(accountId);
GroupInput groupInput = new GroupInput();
groupInput.name = name("Users");
groupInput.members = ImmutableList.of(String.valueOf(accountId.get()));
GroupInfo group = gApi.groups().create(groupInput).get();
Collection<AccountGroup.UUID> groups = groupIncludeCache.getGroupsWithMember(accountId);
assertThat(groups).containsExactly(AccountGroup.uuid(group.id));
}
Aggregations