Merge changes I711cc455,If1b3c188,I8c59564b,Ia7896a1a
* changes: GroupIT: Rename createGroup(name) to createUniqueGroup CmdLineParser: Suppress raw type warnings related to args4j classes Remove unnecessary UiType enum CmdLineParser: Fix Javadoc warnings
This commit is contained in:
@@ -1,32 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Android Open Source Project
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package com.google.gerrit.extensions.client;
|
|
||||||
|
|
||||||
public enum UiType {
|
|
||||||
NONE,
|
|
||||||
GWT,
|
|
||||||
POLYGERRIT;
|
|
||||||
|
|
||||||
public static UiType parse(String str) {
|
|
||||||
if (str != null) {
|
|
||||||
for (UiType type : UiType.values()) {
|
|
||||||
if (type.name().equalsIgnoreCase(str)) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -14,9 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.extensions.common;
|
package com.google.gerrit.extensions.common;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.client.UiType;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class GerritInfo {
|
public class GerritInfo {
|
||||||
public String allProjects;
|
public String allProjects;
|
||||||
public String allUsers;
|
public String allUsers;
|
||||||
@@ -25,5 +22,4 @@ public class GerritInfo {
|
|||||||
public Boolean editGpgKeys;
|
public Boolean editGpgKeys;
|
||||||
public String reportBugUrl;
|
public String reportBugUrl;
|
||||||
public String reportBugText;
|
public String reportBugText;
|
||||||
public Set<UiType> webUis;
|
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@ import com.google.common.base.CharMatcher;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.common.data.ContributorAgreement;
|
import com.google.gerrit.common.data.ContributorAgreement;
|
||||||
import com.google.gerrit.extensions.client.UiType;
|
|
||||||
import com.google.gerrit.extensions.common.AccountsInfo;
|
import com.google.gerrit.extensions.common.AccountsInfo;
|
||||||
import com.google.gerrit.extensions.common.AuthInfo;
|
import com.google.gerrit.extensions.common.AuthInfo;
|
||||||
import com.google.gerrit.extensions.common.ChangeConfigInfo;
|
import com.google.gerrit.extensions.common.ChangeConfigInfo;
|
||||||
@@ -66,7 +65,6 @@ import com.google.inject.Inject;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -304,7 +302,6 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
info.docSearch = docSearcher.isAvailable();
|
info.docSearch = docSearcher.isAvailable();
|
||||||
info.editGpgKeys =
|
info.editGpgKeys =
|
||||||
toBoolean(enableSignedPush && config.getBoolean("gerrit", null, "editGpgKeys", true));
|
toBoolean(enableSignedPush && config.getBoolean("gerrit", null, "editGpgKeys", true));
|
||||||
info.webUis = EnumSet.noneOf(UiType.class);
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -124,7 +124,6 @@ public class CmdLineParser {
|
|||||||
/**
|
/**
|
||||||
* get and consume (consider parsed) a parameter
|
* get and consume (consider parsed) a parameter
|
||||||
*
|
*
|
||||||
* @param name name
|
|
||||||
* @return the consumed parameter
|
* @return the consumed parameter
|
||||||
*/
|
*/
|
||||||
public String consumeParameter() throws CmdLineException {
|
public String consumeParameter() throws CmdLineException {
|
||||||
@@ -158,7 +157,7 @@ public class CmdLineParser {
|
|||||||
* Use during parsing to call additional parameters simulating as if they had been passed from
|
* Use during parsing to call additional parameters simulating as if they had been passed from
|
||||||
* the command line originally.
|
* the command line originally.
|
||||||
*
|
*
|
||||||
* @param String... args A variable amount of parameters to call immediately
|
* @param args A variable amount of parameters to call immediately
|
||||||
* <p>The parameters will be parsed immediately, before the remaining parameter will be
|
* <p>The parameters will be parsed immediately, before the remaining parameter will be
|
||||||
* parsed.
|
* parsed.
|
||||||
* <p>Note: Since this is done outside of the arg4j parsing loop, it will not match exactly
|
* <p>Note: Since this is done outside of the arg4j parsing loop, it will not match exactly
|
||||||
@@ -504,10 +503,16 @@ public class CmdLineParser {
|
|||||||
|
|
||||||
private class QueuedOption {
|
private class QueuedOption {
|
||||||
public final Option option;
|
public final Option option;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public final Setter setter;
|
public final Setter setter;
|
||||||
|
|
||||||
public final String[] requiredOptions;
|
public final String[] requiredOptions;
|
||||||
|
|
||||||
private QueuedOption(Option option, Setter setter, RequiresOptions requiresOptions) {
|
private QueuedOption(
|
||||||
|
Option option,
|
||||||
|
@SuppressWarnings("rawtypes") Setter setter,
|
||||||
|
RequiresOptions requiresOptions) {
|
||||||
this.option = option;
|
this.option = option;
|
||||||
this.setter = setter;
|
this.setter = setter;
|
||||||
this.requiredOptions = requiresOptions != null ? requiresOptions.value() : new String[0];
|
this.requiredOptions = requiresOptions != null ? requiresOptions.value() : new String[0];
|
||||||
@@ -625,6 +630,7 @@ public class CmdLineParser {
|
|||||||
* <p>Note: this is cut & pasted from the parent class in arg4j, it was private and it
|
* <p>Note: this is cut & pasted from the parent class in arg4j, it was private and it
|
||||||
* needed to be exposed.
|
* needed to be exposed.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public OptionHandler findOptionByName(String name) {
|
public OptionHandler findOptionByName(String name) {
|
||||||
for (OptionHandler h : optionsList) {
|
for (OptionHandler h : optionsList) {
|
||||||
NamedOptionDef option = (NamedOptionDef) h.option;
|
NamedOptionDef option = (NamedOptionDef) h.option;
|
||||||
@@ -640,7 +646,10 @@ public class CmdLineParser {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void queueOption(Option option, Setter setter, RequiresOptions requiresOptions) {
|
private void queueOption(
|
||||||
|
Option option,
|
||||||
|
@SuppressWarnings("rawtypes") Setter setter,
|
||||||
|
RequiresOptions requiresOptions) {
|
||||||
if (queuedOptionsByName.put(option.name(), new QueuedOption(option, setter, requiresOptions))
|
if (queuedOptionsByName.put(option.name(), new QueuedOption(option, setter, requiresOptions))
|
||||||
!= null) {
|
!= null) {
|
||||||
throw new IllegalAnnotationError(
|
throw new IllegalAnnotationError(
|
||||||
|
@@ -147,7 +147,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates a group, but with uniquified name.
|
// Creates a group, but with uniquified name.
|
||||||
protected String createGroup(String name) throws Exception {
|
protected String createUniqueGroup() throws Exception {
|
||||||
// TODO(hanwen): rewrite this test in terms of UUID. This requires redoing the assertion helpers
|
// TODO(hanwen): rewrite this test in terms of UUID. This requires redoing the assertion helpers
|
||||||
// too.
|
// too.
|
||||||
AccountGroup.UUID g = groupOperations.newGroup().ownerGroupUuid(adminGroupUuid()).create();
|
AccountGroup.UUID g = groupOperations.newGroup().ownerGroupUuid(adminGroupUuid()).create();
|
||||||
@@ -155,6 +155,8 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String createGroup(String name, String owner) throws Exception {
|
protected String createGroup(String name, String owner) throws Exception {
|
||||||
|
// TODO(hanwen): rewrite to use groupOperations. This requires passing the owner
|
||||||
|
// group's UUID rathen than its name.
|
||||||
name = name(name);
|
name = name(name);
|
||||||
GroupInput in = new GroupInput();
|
GroupInput in = new GroupInput();
|
||||||
in.name = name;
|
in.name = name;
|
||||||
@@ -191,7 +193,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addRemoveMember() throws Exception {
|
public void addRemoveMember() throws Exception {
|
||||||
String g = createGroup("users");
|
String g = createUniqueGroup();
|
||||||
gApi.groups().id(g).addMembers("user");
|
gApi.groups().id(g).addMembers("user");
|
||||||
assertMembers(g, user);
|
assertMembers(g, user);
|
||||||
|
|
||||||
@@ -206,7 +208,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
// Fill the cache for the observed account.
|
// Fill the cache for the observed account.
|
||||||
groupIncludeCache.getGroupsWithMember(accountId);
|
groupIncludeCache.getGroupsWithMember(accountId);
|
||||||
String groupName = createGroup("users");
|
String groupName = createUniqueGroup();
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID(gApi.groups().id(groupName).get().id);
|
AccountGroup.UUID groupUuid = new AccountGroup.UUID(gApi.groups().id(groupName).get().id);
|
||||||
|
|
||||||
gApi.groups().id(groupName).addMembers(username);
|
gApi.groups().id(groupName).addMembers(username);
|
||||||
@@ -238,7 +240,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addMultipleMembers() throws Exception {
|
public void addMultipleMembers() throws Exception {
|
||||||
String g = createGroup("users");
|
String g = createUniqueGroup();
|
||||||
|
|
||||||
String u1 = name("u1");
|
String u1 = name("u1");
|
||||||
accountOperations.newAccount().username(u1).create();
|
accountOperations.newAccount().username(u1).create();
|
||||||
@@ -255,7 +257,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void membersWithAtSignInUsernameCanBeAdded() throws Exception {
|
public void membersWithAtSignInUsernameCanBeAdded() throws Exception {
|
||||||
String g = createGroup("users");
|
String g = createUniqueGroup();
|
||||||
String usernameWithAt = name("u1@something");
|
String usernameWithAt = name("u1@something");
|
||||||
accountOperations.newAccount().username(usernameWithAt).create();
|
accountOperations.newAccount().username(usernameWithAt).create();
|
||||||
|
|
||||||
@@ -269,7 +271,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void membersWithAtSignInUsernameAreNotConfusedWithSimilarUsernames() throws Exception {
|
public void membersWithAtSignInUsernameAreNotConfusedWithSimilarUsernames() throws Exception {
|
||||||
String g = createGroup("users");
|
String g = createUniqueGroup();
|
||||||
String usernameWithAt = name("u1@something");
|
String usernameWithAt = name("u1@something");
|
||||||
accountOperations.newAccount().username(usernameWithAt).create();
|
accountOperations.newAccount().username(usernameWithAt).create();
|
||||||
String usernameWithoutAt = name("u1something");
|
String usernameWithoutAt = name("u1something");
|
||||||
@@ -291,8 +293,8 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void includeRemoveGroup() throws Exception {
|
public void includeRemoveGroup() throws Exception {
|
||||||
String p = createGroup("parent");
|
String p = createUniqueGroup();
|
||||||
String g = createGroup("newGroup");
|
String g = createUniqueGroup();
|
||||||
gApi.groups().id(p).addGroups(g);
|
gApi.groups().id(p).addGroups(g);
|
||||||
assertIncludes(p, g);
|
assertIncludes(p, g);
|
||||||
|
|
||||||
@@ -302,7 +304,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void includeExternalGroup() throws Exception {
|
public void includeExternalGroup() throws Exception {
|
||||||
String g = createGroup("group");
|
String g = createUniqueGroup();
|
||||||
String subgroupUuid = SystemGroupBackend.REGISTERED_USERS.get();
|
String subgroupUuid = SystemGroupBackend.REGISTERED_USERS.get();
|
||||||
gApi.groups().id(g).addGroups(subgroupUuid);
|
gApi.groups().id(g).addGroups(subgroupUuid);
|
||||||
|
|
||||||
@@ -319,8 +321,8 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void includeExistingGroup_OK() throws Exception {
|
public void includeExistingGroup_OK() throws Exception {
|
||||||
String p = createGroup("parent");
|
String p = createUniqueGroup();
|
||||||
String g = createGroup("newGroup");
|
String g = createUniqueGroup();
|
||||||
gApi.groups().id(p).addGroups(g);
|
gApi.groups().id(p).addGroups(g);
|
||||||
assertIncludes(p, g);
|
assertIncludes(p, g);
|
||||||
gApi.groups().id(p).addGroups(g);
|
gApi.groups().id(p).addGroups(g);
|
||||||
@@ -329,9 +331,9 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addMultipleIncludes() throws Exception {
|
public void addMultipleIncludes() throws Exception {
|
||||||
String p = createGroup("parent");
|
String p = createUniqueGroup();
|
||||||
String g1 = createGroup("newGroup1");
|
String g1 = createUniqueGroup();
|
||||||
String g2 = createGroup("newGroup2");
|
String g2 = createUniqueGroup();
|
||||||
List<String> groups = new ArrayList<>();
|
List<String> groups = new ArrayList<>();
|
||||||
groups.add(g1);
|
groups.add(g1);
|
||||||
groups.add(g2);
|
groups.add(g2);
|
||||||
@@ -637,22 +639,22 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listEmptyGroupIncludes() throws Exception {
|
public void listEmptyGroupIncludes() throws Exception {
|
||||||
String gx = createGroup("gx");
|
String gx = createUniqueGroup();
|
||||||
assertThat(gApi.groups().id(gx).includedGroups()).isEmpty();
|
assertThat(gApi.groups().id(gx).includedGroups()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void includeNonExistingGroup() throws Exception {
|
public void includeNonExistingGroup() throws Exception {
|
||||||
String gx = createGroup("gx");
|
String gx = createUniqueGroup();
|
||||||
exception.expect(UnprocessableEntityException.class);
|
exception.expect(UnprocessableEntityException.class);
|
||||||
gApi.groups().id(gx).addGroups("non-existing");
|
gApi.groups().id(gx).addGroups("non-existing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listNonEmptyGroupIncludes() throws Exception {
|
public void listNonEmptyGroupIncludes() throws Exception {
|
||||||
String gx = createGroup("gx");
|
String gx = createUniqueGroup();
|
||||||
String gy = createGroup("gy");
|
String gy = createUniqueGroup();
|
||||||
String gz = createGroup("gz");
|
String gz = createUniqueGroup();
|
||||||
gApi.groups().id(gx).addGroups(gy);
|
gApi.groups().id(gx).addGroups(gy);
|
||||||
gApi.groups().id(gx).addGroups(gz);
|
gApi.groups().id(gx).addGroups(gz);
|
||||||
assertIncludes(gApi.groups().id(gx).includedGroups(), gy, gz);
|
assertIncludes(gApi.groups().id(gx).includedGroups(), gy, gz);
|
||||||
@@ -660,8 +662,8 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listOneIncludeMember() throws Exception {
|
public void listOneIncludeMember() throws Exception {
|
||||||
String gx = createGroup("gx");
|
String gx = createUniqueGroup();
|
||||||
String gy = createGroup("gy");
|
String gy = createUniqueGroup();
|
||||||
gApi.groups().id(gx).addGroups(gy);
|
gApi.groups().id(gx).addGroups(gy);
|
||||||
assertIncludes(gApi.groups().id(gx).includedGroups(), gy);
|
assertIncludes(gApi.groups().id(gx).includedGroups(), gy);
|
||||||
}
|
}
|
||||||
@@ -674,13 +676,13 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listEmptyGroupMembers() throws Exception {
|
public void listEmptyGroupMembers() throws Exception {
|
||||||
String group = createGroup("empty");
|
String group = createUniqueGroup();
|
||||||
assertThat(gApi.groups().id(group).members()).isEmpty();
|
assertThat(gApi.groups().id(group).members()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listNonEmptyGroupMembers() throws Exception {
|
public void listNonEmptyGroupMembers() throws Exception {
|
||||||
String group = createGroup("group");
|
String group = createUniqueGroup();
|
||||||
String user1 = name("user1");
|
String user1 = name("user1");
|
||||||
accountOperations.newAccount().username(user1).create();
|
accountOperations.newAccount().username(user1).create();
|
||||||
String user2 = name("user2");
|
String user2 = name("user2");
|
||||||
@@ -692,7 +694,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listOneGroupMember() throws Exception {
|
public void listOneGroupMember() throws Exception {
|
||||||
String group = createGroup("group");
|
String group = createUniqueGroup();
|
||||||
String user = name("user1");
|
String user = name("user1");
|
||||||
accountOperations.newAccount().username(user).create();
|
accountOperations.newAccount().username(user).create();
|
||||||
gApi.groups().id(group).addMembers(user);
|
gApi.groups().id(group).addMembers(user);
|
||||||
@@ -702,17 +704,17 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listGroupMembersRecursively() throws Exception {
|
public void listGroupMembersRecursively() throws Exception {
|
||||||
String gx = createGroup("gx");
|
String gx = createUniqueGroup();
|
||||||
String ux = name("ux");
|
String ux = name("ux");
|
||||||
accountOperations.newAccount().username(ux).create();
|
accountOperations.newAccount().username(ux).create();
|
||||||
gApi.groups().id(gx).addMembers(ux);
|
gApi.groups().id(gx).addMembers(ux);
|
||||||
|
|
||||||
String gy = createGroup("gy");
|
String gy = createUniqueGroup();
|
||||||
String uy = name("uy");
|
String uy = name("uy");
|
||||||
accountOperations.newAccount().username(uy).create();
|
accountOperations.newAccount().username(uy).create();
|
||||||
gApi.groups().id(gy).addMembers(uy);
|
gApi.groups().id(gy).addMembers(uy);
|
||||||
|
|
||||||
String gz = createGroup("gz");
|
String gz = createUniqueGroup();
|
||||||
String uz = name("uz");
|
String uz = name("uz");
|
||||||
accountOperations.newAccount().username(uz).create();
|
accountOperations.newAccount().username(uz).create();
|
||||||
gApi.groups().id(gz).addMembers(uz);
|
gApi.groups().id(gz).addMembers(uz);
|
||||||
@@ -725,7 +727,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void usersSeeTheirDirectMembershipWhenListingMembersRecursively() throws Exception {
|
public void usersSeeTheirDirectMembershipWhenListingMembersRecursively() throws Exception {
|
||||||
String group = createGroup("group");
|
String group = createUniqueGroup();
|
||||||
gApi.groups().id(group).addMembers(user.username);
|
gApi.groups().id(group).addMembers(user.username);
|
||||||
|
|
||||||
setApiUser(user);
|
setApiUser(user);
|
||||||
@@ -734,8 +736,8 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void usersDoNotSeeTheirIndirectMembershipWhenListingMembersRecursively() throws Exception {
|
public void usersDoNotSeeTheirIndirectMembershipWhenListingMembersRecursively() throws Exception {
|
||||||
String group1 = createGroup("group1");
|
String group1 = createUniqueGroup();
|
||||||
String group2 = createGroup("group2");
|
String group2 = createUniqueGroup();
|
||||||
gApi.groups().id(group1).addGroups(group2);
|
gApi.groups().id(group1).addGroups(group2);
|
||||||
gApi.groups().id(group2).addMembers(user.username);
|
gApi.groups().id(group2).addMembers(user.username);
|
||||||
|
|
||||||
@@ -791,7 +793,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getGroupsByOwner() throws Exception {
|
public void getGroupsByOwner() throws Exception {
|
||||||
String parent = createGroup("test-parent");
|
String parent = createUniqueGroup();
|
||||||
List<String> children =
|
List<String> children =
|
||||||
Arrays.asList(createGroup("test-child1", parent), createGroup("test-child2", parent));
|
Arrays.asList(createGroup("test-child1", parent), createGroup("test-child2", parent));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user