Search in sources :

Example 11 with InternalGroup

use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.

the class GroupConfigTest method specifiedCreatedOnIsRespectedForNewGroup.

@Test
public void specifiedCreatedOnIsRespectedForNewGroup() throws Exception {
    Instant createdOn = toInstant(LocalDate.of(2017, Month.DECEMBER, 11).atTime(13, 44, 10));
    InternalGroupCreation groupCreation = getPrefilledGroupCreationBuilder().build();
    GroupDelta groupDelta = GroupDelta.builder().setUpdatedOn(createdOn).build();
    createGroup(groupCreation, groupDelta);
    Optional<InternalGroup> group = loadGroup(groupCreation.getGroupUUID());
    assertThatGroup(group).value().createdOn().isEqualTo(createdOn);
}
Also used : Instant(java.time.Instant) InternalGroup(com.google.gerrit.entities.InternalGroup) Test(org.junit.Test)

Example 12 with InternalGroup

use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.

the class GroupConfigTest method groupCanBeLoadedAtASpecificRevision.

@Test
public void groupCanBeLoadedAtASpecificRevision() throws Exception {
    createArbitraryGroup(groupUuid);
    AccountGroup.NameKey firstName = AccountGroup.nameKey("Bots");
    GroupDelta groupDelta1 = GroupDelta.builder().setName(firstName).build();
    updateGroup(groupUuid, groupDelta1);
    RevCommit commitAfterUpdate1 = getLatestCommitForGroup(groupUuid);
    GroupDelta groupDelta2 = GroupDelta.builder().setName(AccountGroup.nameKey("Robots")).build();
    updateGroup(groupUuid, groupDelta2);
    GroupConfig groupConfig = GroupConfig.loadForGroupSnapshot(projectName, repository, groupUuid, commitAfterUpdate1.copy());
    Optional<InternalGroup> group = groupConfig.getLoadedGroup();
    assertThatGroup(group).value().nameKey().isEqualTo(firstName);
    assertThatGroup(group).value().refState().isEqualTo(commitAfterUpdate1.copy());
}
Also used : AccountGroup(com.google.gerrit.entities.AccountGroup) RevCommit(org.eclipse.jgit.revwalk.RevCommit) InternalGroup(com.google.gerrit.entities.InternalGroup) Test(org.junit.Test)

Example 13 with InternalGroup

use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.

the class ListGroupsCommand method run.

@Override
public void run() throws Exception {
    enableGracefulStop();
    if (listGroups.getUser() != null && !listGroups.getProjects().isEmpty()) {
        throw die("--user and --project options are not compatible.");
    }
    ColumnFormatter formatter = new ColumnFormatter(stdout, '\t');
    for (GroupInfo info : listGroups.get()) {
        formatter.addColumn(MoreObjects.firstNonNull(info.name, "n/a"));
        if (verboseOutput) {
            Optional<InternalGroup> group = info.ownerId != null ? groupCache.get(AccountGroup.uuid(Url.decode(info.ownerId))) : Optional.empty();
            formatter.addColumn(Url.decode(info.id));
            formatter.addColumn(Strings.nullToEmpty(info.description));
            formatter.addColumn(group.map(InternalGroup::getName).orElse("n/a"));
            formatter.addColumn(group.map(g -> g.getGroupUUID().get()).orElse(""));
            formatter.addColumn(Boolean.toString(MoreObjects.firstNonNull(info.options.visibleToAll, Boolean.FALSE)));
        }
        formatter.nextLine();
    }
    formatter.finish();
}
Also used : GroupInfo(com.google.gerrit.extensions.common.GroupInfo) ColumnFormatter(com.google.gerrit.server.ioutil.ColumnFormatter) InternalGroup(com.google.gerrit.entities.InternalGroup)

Example 14 with InternalGroup

use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.

the class SchemaCreatorImpl method createGroup.

private void createGroup(Repository allUsersRepo, InternalGroupCreation groupCreation, GroupDelta groupDelta) throws ConfigInvalidException, IOException {
    InternalGroup createdGroup = createGroupInNoteDb(allUsersRepo, groupCreation, groupDelta);
    index(createdGroup);
}
Also used : InternalGroup(com.google.gerrit.entities.InternalGroup)

Example 15 with InternalGroup

use of com.google.gerrit.entities.InternalGroup in project gerrit by GerritCodeReview.

the class GroupQueryBuilder method parseGroup.

private AccountGroup.UUID parseGroup(String groupNameOrUuid) throws QueryParseException {
    Optional<InternalGroup> group = args.groupCache.get(AccountGroup.uuid(groupNameOrUuid));
    if (group.isPresent()) {
        return group.get().getGroupUUID();
    }
    GroupReference groupReference = GroupBackends.findBestSuggestion(args.groupBackend, groupNameOrUuid);
    if (groupReference == null) {
        throw error("Group " + groupNameOrUuid + " not found");
    }
    return groupReference.getUUID();
}
Also used : GroupReference(com.google.gerrit.entities.GroupReference) InternalGroup(com.google.gerrit.entities.InternalGroup)

Aggregations

InternalGroup (com.google.gerrit.entities.InternalGroup)41 AccountGroup (com.google.gerrit.entities.AccountGroup)18 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)6 AccountGroupMemberAudit (com.google.gerrit.entities.AccountGroupMemberAudit)5 GroupReference (com.google.gerrit.entities.GroupReference)5 Account (com.google.gerrit.entities.Account)4 AccountGroupByIdAudit (com.google.gerrit.entities.AccountGroupByIdAudit)4 GroupInfo (com.google.gerrit.extensions.common.GroupInfo)4 Instant (java.time.Instant)4 GroupDescription (com.google.gerrit.entities.GroupDescription)3 NoSuchGroupException (com.google.gerrit.exceptions.NoSuchGroupException)3 InternalGroupDescription (com.google.gerrit.server.group.InternalGroupDescription)3 GroupDelta (com.google.gerrit.server.group.db.GroupDelta)3 HashSet (java.util.HashSet)3 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)2 ConsistencyProblemInfo (com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo)2 TraceTimer (com.google.gerrit.server.logging.TraceContext.TraceTimer)2 IOException (java.io.IOException)2 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)2