Search in sources :

Example 21 with GroupInput

use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.

the class GroupsIT method onlyVisibleGroupsReturned.

@Test
public void onlyVisibleGroupsReturned() throws Exception {
    String newGroupName = name("newGroup");
    GroupInput in = new GroupInput();
    in.name = newGroupName;
    in.description = "a hidden group";
    in.visibleToAll = false;
    in.ownerId = adminGroupUuid().get();
    gApi.groups().create(in);
    requestScopeOperations.setApiUser(user.id());
    assertThatMap(gApi.groups().list().getAsMap()).keys().doesNotContain(newGroupName);
    requestScopeOperations.setApiUser(admin.id());
    gApi.groups().id(newGroupName).addMembers(user.username());
    requestScopeOperations.setApiUser(user.id());
    assertThatMap(gApi.groups().list().getAsMap()).keys().contains(newGroupName);
}
Also used : GroupInput(com.google.gerrit.extensions.api.groups.GroupInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 22 with GroupInput

use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.

the class RefAdvertisementIT method createGroup.

private AccountGroup.UUID createGroup(String name, @Nullable AccountGroup.UUID ownerGroup, TestAccount... members) throws RestApiException {
    GroupInput groupInput = new GroupInput();
    groupInput.name = name(name);
    groupInput.ownerId = ownerGroup != null ? ownerGroup.get() : null;
    groupInput.members = Arrays.stream(members).map(m -> String.valueOf(m.id().get())).collect(toList());
    return AccountGroup.uuid(gApi.groups().create(groupInput).get().id);
}
Also used : GroupInput(com.google.gerrit.extensions.api.groups.GroupInput)

Example 23 with GroupInput

use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.

the class ImpersonationIT method setUp.

@Before
public void setUp() throws Exception {
    anonRestSession = new RestSession(server, null);
    admin2 = accountCreator.admin2();
    GroupInput gi = new GroupInput();
    gi.name = name("New-Group");
    gi.members = ImmutableList.of(user.id().toString());
    newGroup = gApi.groups().create(gi).get();
}
Also used : GroupInput(com.google.gerrit.extensions.api.groups.GroupInput) RestSession(com.google.gerrit.acceptance.RestSession) Before(org.junit.Before)

Example 24 with GroupInput

use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.

the class GroupOperationsImplTest method groupNotCreatedByTestApiCanBeRetrieved.

@Test
public void groupNotCreatedByTestApiCanBeRetrieved() throws Exception {
    GroupInput input = createArbitraryGroupInput();
    input.name = "unique group not created via test API";
    AccountGroup.UUID groupUuid = createGroupInServer(input);
    TestGroup foundGroup = groupOperations.group(groupUuid).get();
    assertThat(foundGroup.groupUuid()).isEqualTo(groupUuid);
    assertThat(foundGroup.name()).isEqualTo("unique group not created via test API");
}
Also used : GroupInput(com.google.gerrit.extensions.api.groups.GroupInput) AccountGroup(com.google.gerrit.entities.AccountGroup) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 25 with GroupInput

use of com.google.gerrit.extensions.api.groups.GroupInput in project gerrit by GerritCodeReview.

the class AbstractQueryGroupsTest method createGroupWithDescription.

protected GroupInfo createGroupWithDescription(String name, String description, AccountInfo... members) throws Exception {
    GroupInput in = new GroupInput();
    in.name = name;
    in.description = description;
    in.members = Arrays.asList(members).stream().map(a -> String.valueOf(a._accountId)).collect(toList());
    return gApi.groups().create(in).get();
}
Also used : GroupInput(com.google.gerrit.extensions.api.groups.GroupInput)

Aggregations

GroupInput (com.google.gerrit.extensions.api.groups.GroupInput)27 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)13 Test (org.junit.Test)13 GroupInfo (com.google.gerrit.extensions.common.GroupInfo)9 GroupAssert.assertGroupInfo (com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo)6 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)5 TestAccount (com.google.gerrit.acceptance.TestAccount)5 AccountGroup (com.google.gerrit.entities.AccountGroup)5 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)4 Account (com.google.gerrit.entities.Account)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables (com.google.common.collect.Iterables)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 ExtensionRegistry (com.google.gerrit.acceptance.ExtensionRegistry)2 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)2 NoHttpd (com.google.gerrit.acceptance.NoHttpd)2 ProjectOperations (com.google.gerrit.acceptance.testsuite.project.ProjectOperations)2