Merge changes Icf50c0be,I90bcd7d4
* changes: Ensure that system groups can be retrieved from the index during tests Correct group lookup by name from the index
This commit is contained in:
@@ -342,6 +342,20 @@ public abstract class AbstractDaemonTest {
|
|||||||
server.getTestInjector().injectMembers(this);
|
server.getTestInjector().injectMembers(this);
|
||||||
Transport.register(inProcessProtocol);
|
Transport.register(inProcessProtocol);
|
||||||
toClose = Collections.synchronizedList(new ArrayList<Repository>());
|
toClose = Collections.synchronizedList(new ArrayList<Repository>());
|
||||||
|
|
||||||
|
// All groups which were added during the server start (e.g. in SchemaCreator) aren't contained
|
||||||
|
// in the instance of the group index which is available here and in tests. There are two
|
||||||
|
// reasons:
|
||||||
|
// 1) No group index is available in SchemaCreator when using an in-memory database. (This could
|
||||||
|
// be fixed by using the IndexManagerOnInit in InMemoryDatabase similar as BaseInit uses it.)
|
||||||
|
// 2) During the on-init part of the server start, we use another instance of the index than
|
||||||
|
// later on. As test indexes are non-permanent, closing an instance and opening another one
|
||||||
|
// removes all indexed data.
|
||||||
|
// As a workaround, we simply reindex all available groups here.
|
||||||
|
for (AccountGroup group : groupCache.all()) {
|
||||||
|
groupCache.evict(group);
|
||||||
|
}
|
||||||
|
|
||||||
admin = accountCreator.admin();
|
admin = accountCreator.admin();
|
||||||
user = accountCreator.user();
|
user = accountCreator.user();
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ import org.junit.Test;
|
|||||||
public class GroupsIT extends AbstractDaemonTest {
|
public class GroupsIT extends AbstractDaemonTest {
|
||||||
@Inject @ServerInitiated private Provider<GroupsUpdate> groupsUpdateProvider;
|
@Inject @ServerInitiated private Provider<GroupsUpdate> groupsUpdateProvider;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void systemGroupCanBeRetrievedFromIndex() throws Exception {
|
||||||
|
List<GroupInfo> groupInfos = gApi.groups().query("name:Administrators").get();
|
||||||
|
assertThat(groupInfos).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addToNonExistingGroup_NotFound() throws Exception {
|
public void addToNonExistingGroup_NotFound() throws Exception {
|
||||||
exception.expect(ResourceNotFoundException.class);
|
exception.expect(ResourceNotFoundException.class);
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ public class GroupPredicates {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<AccountGroup> name(String name) {
|
public static Predicate<AccountGroup> name(String name) {
|
||||||
return new GroupPredicate(
|
return new GroupPredicate(GroupField.NAME, GroupQueryBuilder.FIELD_NAME, name);
|
||||||
GroupField.NAME, GroupQueryBuilder.FIELD_NAME, name.toLowerCase(Locale.US));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Predicate<AccountGroup> owner(AccountGroup.UUID ownerUuid) {
|
public static Predicate<AccountGroup> owner(AccountGroup.UUID ownerUuid) {
|
||||||
|
|||||||
@@ -185,9 +185,9 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
|
|||||||
public void byName() throws Exception {
|
public void byName() throws Exception {
|
||||||
assertQuery("name:non-existing");
|
assertQuery("name:non-existing");
|
||||||
|
|
||||||
GroupInfo group = createGroup(name("group"));
|
GroupInfo group = createGroup(name("Group"));
|
||||||
assertQuery("name:" + group.name, group);
|
assertQuery("name:" + group.name, group);
|
||||||
assertQuery("name:" + group.name.toUpperCase(Locale.US), group);
|
assertQuery("name:" + group.name.toLowerCase(Locale.US));
|
||||||
|
|
||||||
// only exact match
|
// only exact match
|
||||||
GroupInfo groupWithHyphen = createGroup(name("group-with-hyphen"));
|
GroupInfo groupWithHyphen = createGroup(name("group-with-hyphen"));
|
||||||
|
|||||||
Reference in New Issue
Block a user