Search in sources :

Example 6 with GroupInfo

use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.

the class GroupsImpl method create.

@Override
public GroupApi create(GroupInput in) throws RestApiException {
    if (checkNotNull(in, "GroupInput").name == null) {
        throw new BadRequestException("GroupInput must specify name");
    }
    try {
        CreateGroup impl = createGroup.create(in.name);
        permissionBackend.user(user).checkAny(GlobalPermission.fromAnnotation(impl.getClass()));
        GroupInfo info = impl.apply(TopLevelResource.INSTANCE, in);
        return id(info.id);
    } catch (Exception e) {
        throw asRestApiException("Cannot create group " + in.name, e);
    }
}
Also used : GroupInfo(com.google.gerrit.extensions.common.GroupInfo) CreateGroup(com.google.gerrit.server.group.CreateGroup) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Example 7 with GroupInfo

use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.

the class AbstractQueryGroupsTest method withStart.

@Test
public void withStart() throws Exception {
    GroupInfo group1 = createGroup(name("group1"));
    GroupInfo group2 = createGroup(name("group2"));
    GroupInfo group3 = createGroup(name("group3"));
    String query = "uuid:" + group1.id + " OR uuid:" + group2.id + " OR uuid:" + group3.id;
    List<GroupInfo> result = assertQuery(query, group1, group2, group3);
    assertQuery(newQuery(query).withStart(1), result.subList(1, 3));
}
Also used : GroupInfo(com.google.gerrit.extensions.common.GroupInfo) Test(org.junit.Test)

Example 8 with GroupInfo

use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.

the class AbstractQueryGroupsTest method byDefaultField.

@Test
public void byDefaultField() throws Exception {
    GroupInfo group1 = createGroup(name("foo-group"));
    GroupInfo group2 = createGroup(name("group2"));
    GroupInfo group3 = createGroupWithDescription(name("group3"), "decription that contains foo and the UUID of group2: " + group2.id);
    assertQuery("non-existing");
    assertQuery("foo", group1, group3);
    assertQuery(group2.id, group2, group3);
}
Also used : GroupInfo(com.google.gerrit.extensions.common.GroupInfo) Test(org.junit.Test)

Example 9 with GroupInfo

use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.

the class AbstractQueryGroupsTest method format.

protected String format(Iterable<GroupInfo> groups) {
    StringBuilder b = new StringBuilder();
    b.append("[");
    Iterator<GroupInfo> it = groups.iterator();
    while (it.hasNext()) {
        GroupInfo g = it.next();
        b.append("{").append(g.id).append(", ").append("name=").append(g.name).append(", ").append("groupId=").append(g.groupId).append(", ").append("url=").append(g.url).append(", ").append("ownerId=").append(g.ownerId).append(", ").append("owner=").append(g.owner).append(", ").append("description=").append(g.description).append(", ").append("visibleToAll=").append(toBoolean(g.options.visibleToAll)).append("}");
        if (it.hasNext()) {
            b.append(", ");
        }
    }
    b.append("]");
    return b.toString();
}
Also used : GroupInfo(com.google.gerrit.extensions.common.GroupInfo)

Example 10 with GroupInfo

use of com.google.gerrit.extensions.common.GroupInfo in project gerrit by GerritCodeReview.

the class AbstractQueryGroupsTest method byOwner.

@Test
public void byOwner() throws Exception {
    GroupInfo ownerGroup = createGroup(name("owner-group"));
    GroupInfo group = createGroupWithOwner(name("group"), ownerGroup);
    createGroup(name("group2"));
    assertQuery("owner:" + group.id);
    // ownerGroup owns itself
    assertQuery("owner:" + ownerGroup.id, group, ownerGroup);
    assertQuery("owner:" + ownerGroup.name, group, ownerGroup);
}
Also used : GroupInfo(com.google.gerrit.extensions.common.GroupInfo) Test(org.junit.Test)

Aggregations

GroupInfo (com.google.gerrit.extensions.common.GroupInfo)38 Test (org.junit.Test)20 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)11 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)9 GroupAssert.assertGroupInfo (com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo)8 GroupDescription (com.google.gerrit.common.data.GroupDescription)5 ArrayList (java.util.ArrayList)5 GroupReference (com.google.gerrit.common.data.GroupReference)4 GroupInput (com.google.gerrit.extensions.api.groups.GroupInput)4 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)4 TestAccount (com.google.gerrit.acceptance.TestAccount)3 NoSuchGroupException (com.google.gerrit.common.errors.NoSuchGroupException)3 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)3 GroupControl (com.google.gerrit.server.account.GroupControl)3 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 AuthException (com.google.gerrit.extensions.restapi.AuthException)2 Account (com.google.gerrit.reviewdb.client.Account)2 AccountGroupById (com.google.gerrit.reviewdb.client.AccountGroupById)2 Project (com.google.gerrit.reviewdb.client.Project)2 Message (com.google.gerrit.testutil.FakeEmailSender.Message)2