use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.
the class ProjectCacheIT method pluginConfig_cachedValueEqualsConfigValue.
@Test
public void pluginConfig_cachedValueEqualsConfigValue() throws Exception {
GroupReference group = GroupReference.create(AccountGroup.uuid("uuid"), "local-group-name");
try (AbstractDaemonTest.ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updatePluginConfig("important-plugin", cfg -> {
cfg.setGroupReference("group-config-name", group);
cfg.setString("key", "my-plugin-value");
});
u.save();
}
PluginConfig pluginConfig = projectCache.get(project).get().getPluginConfig("important-plugin");
assertThat(pluginConfig.getString("key")).isEqualTo("my-plugin-value");
assertThat(pluginConfig.getGroupReference("group-config-name")).isPresent();
assertThat(pluginConfig.getGroupReference("group-config-name")).hasValue(group);
}
use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.
the class ProjectCacheIT method pluginConfig_inheritedCachedValueEqualsConfigValue.
@Test
public void pluginConfig_inheritedCachedValueEqualsConfigValue() throws Exception {
GroupReference group = GroupReference.create(AccountGroup.uuid("uuid"), "local-group-name");
try (AbstractDaemonTest.ProjectConfigUpdate u = updateProject(allProjects)) {
u.getConfig().updatePluginConfig("important-plugin", cfg -> {
cfg.setGroupReference("group-config-name", group);
cfg.setString("key", "my-plugin-value");
});
u.save();
}
PluginConfig pluginConfig = pluginConfigFactory.getFromProjectConfigWithInheritance(project, "important-plugin");
assertThat(pluginConfig.getString("key")).isEqualTo("my-plugin-value");
assertThat(pluginConfig.getGroupReference("group-config-name")).isPresent();
assertThat(pluginConfig.getGroupReference("group-config-name")).hasValue(group);
}
use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.
the class GroupReferenceSerializerTest method roundTripWithMinimalValues.
@Test
public void roundTripWithMinimalValues() {
GroupReference groupReferenceAutoValue = GroupReference.create("name");
assertThat(deserialize(serialize(groupReferenceAutoValue))).isEqualTo(groupReferenceAutoValue);
}
use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.
the class GroupNameNotesTest method updateGroupNamesWithEmptyCollectionClearsAllNotes.
@Test
public void updateGroupNamesWithEmptyCollectionClearsAllNotes() throws Exception {
GroupReference g1 = newGroup("a");
GroupReference g2 = newGroup("b");
PersonIdent ident = newPersonIdent();
updateAllGroups(ident, g1, g2);
assertThat(GroupNameNotes.loadAllGroups(repo)).containsExactly(g1, g2);
updateAllGroups(ident);
assertThat(GroupNameNotes.loadAllGroups(repo)).isEmpty();
ImmutableList<CommitInfo> log = log();
assertThat(log).hasSize(2);
assertThat(log.get(1)).message().isEqualTo("Store 0 group names");
}
use of com.google.gerrit.entities.GroupReference in project gerrit by GerritCodeReview.
the class GroupNameNotesTest method updateGroupNamesOverwritesExistingNotes.
@Test
public void updateGroupNamesOverwritesExistingNotes() throws Exception {
GroupReference g1 = newGroup("a");
GroupReference g2 = newGroup("b");
try (TestRepository<Repository> tr = new TestRepository<>(repo)) {
ObjectId k1 = getNoteKey(g1);
ObjectId k2 = getNoteKey(g2);
ObjectId k3 = GroupNameNotes.getNoteKey(AccountGroup.nameKey("c"));
PersonIdent ident = newPersonIdent();
ObjectId origCommitId = tr.branch(REFS_GROUPNAMES).commit().message("Prepopulate group name").author(ident).committer(ident).add(k1.name(), "[group]\n\tuuid = a-1\n\tname = a\nanotherKey = foo\n").add(k2.name(), "[group]\n\tuuid = a-1\n\tname = b\n").add(k3.name(), "[group]\n\tuuid = c-3\n\tname = c\n").create().copy();
ident = newPersonIdent();
updateAllGroups(ident, g1, g2);
assertThat(GroupNameNotes.loadAllGroups(repo)).containsExactly(g1, g2);
ImmutableList<CommitInfo> log = log();
assertThat(log).hasSize(2);
assertThat(log.get(0)).commit().isEqualTo(origCommitId.name());
assertThat(log.get(1)).message().isEqualTo("Store 2 group names");
assertThat(log.get(1)).author().matches(ident);
assertThat(log.get(1)).committer().matches(ident);
}
// Old note content was overwritten.
assertThat(readNameNote(g1)).isEqualTo("[group]\n\tuuid = a-1\n\tname = a\n");
}
Aggregations