use of com.google.gerrit.server.project.ProjectState in project gerrit by GerritCodeReview.
the class ProjectLevelConfigIT method withInheritance.
@Test
public void withInheritance() throws Exception {
String configName = "test.config";
Config parentCfg = new Config();
parentCfg.setString("s1", null, "k1", "parentValue1");
parentCfg.setString("s1", null, "k2", "parentValue2");
parentCfg.setString("s2", "ss", "k3", "parentValue3");
parentCfg.setString("s2", "ss", "k4", "parentValue4");
pushFactory.create(admin.newIdent(), testRepo, "Create Project Level Config", configName, parentCfg.toText()).to(RefNames.REFS_CONFIG).assertOkStatus();
Project.NameKey childProject = projectOperations.newProject().parent(project).create();
TestRepository<?> childTestRepo = cloneProject(childProject);
fetch(childTestRepo, RefNames.REFS_CONFIG + ":refs/heads/config");
childTestRepo.reset("refs/heads/config");
Config cfg = new Config();
cfg.setString("s1", null, "k1", "childValue1");
cfg.setString("s2", "ss", "k3", "childValue2");
pushFactory.create(admin.newIdent(), childTestRepo, "Create Project Level Config", configName, cfg.toText()).to(RefNames.REFS_CONFIG).assertOkStatus();
ProjectState state = projectCache.get(childProject).get();
Config expectedCfg = new Config();
expectedCfg.setString("s1", null, "k1", "childValue1");
expectedCfg.setString("s1", null, "k2", "parentValue2");
expectedCfg.setString("s2", "ss", "k3", "childValue2");
expectedCfg.setString("s2", "ss", "k4", "parentValue4");
assertThat(state.getConfig(configName).getWithInheritance().toText()).isEqualTo(expectedCfg.toText());
assertThat(state.getConfig(configName).get().toText()).isEqualTo(cfg.toText());
}
Aggregations