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);
}
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());
}
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();
}
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);
}
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();
}
Aggregations