Add group query operator to match groups by owner

Change-Id: Ifcbbb1e2694d57f887a2282e543fdedbe571a43e
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-01-04 12:00:33 +01:00
parent c109ec165a
commit e661af0d43
4 changed files with 36 additions and 0 deletions

View File

@@ -229,6 +229,18 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
assertQuery("description:\"\"");
}
@Test
public void byOwner() throws Exception {
assertQuery("owner:non-existing");
GroupInfo ownerGroup = createGroup(name("owner-group"));
GroupInfo group = createGroupWithOwner(name("group"), ownerGroup);
createGroup(name("group2"));
// ownerGroup owns itself
assertQuery("owner:" + ownerGroup.id, group, ownerGroup);
}
@Test
public void withLimit() throws Exception {
GroupInfo group1 = createGroup(name("group1"));
@@ -298,6 +310,14 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
return gApi.groups().create(in).get();
}
protected GroupInfo createGroupWithOwner(String name, GroupInfo ownerGroup)
throws Exception {
GroupInput in = new GroupInput();
in.name = name;
in.ownerId = ownerGroup.id;
return gApi.groups().create(in).get();
}
protected GroupInfo getGroup(AccountGroup.UUID uuid) throws Exception {
return gApi.groups().id(uuid.get()).get();
}