use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnNullIfNoSecretConfigExistBySecretConfigId.
@Test
public void shouldReturnNullIfNoSecretConfigExistBySecretConfigId() throws Exception {
GoConfigMother configMother = new GoConfigMother();
BasicCruiseConfig config = GoConfigMother.defaultCruiseConfig();
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1", "job1");
expectLoad(config);
assertThat(goConfigService.getSecretConfigById("invalid"), is(nullValue()));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldRegisterBaseUrlChangeListener.
@Test
public void shouldRegisterBaseUrlChangeListener() throws Exception {
CruiseConfig cruiseConfig = new GoConfigMother().cruiseConfigWithOnePipelineGroup();
when(goConfigDao.load()).thenReturn(cruiseConfig);
goConfigService.initialize();
verify(goConfigDao).registerListener(any(BaseUrlChangeListener.class));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldIgnoreXmlEntitiesAndReplaceThemWithEmptyString_DuringPipelineGroupPartialSave.
@Test
public void shouldIgnoreXmlEntitiesAndReplaceThemWithEmptyString_DuringPipelineGroupPartialSave() throws Exception {
ArgumentCaptor<FullConfigUpdateCommand> commandArgumentCaptor = ArgumentCaptor.forClass(FullConfigUpdateCommand.class);
File targetFile = TempFiles.createUniqueFile("somefile");
FileUtils.writeStringToFile(targetFile, "CONTENTS_OF_FILE", StandardCharsets.UTF_8);
cruiseConfig = new BasicCruiseConfig();
expectLoad(cruiseConfig);
new GoConfigMother().addPipelineWithGroup(cruiseConfig, "group_name", "pipeline1", "stage_name", "job_name");
expectLoadForEditing(cruiseConfig);
when(goConfigDao.md5OfConfigFile()).thenReturn("md5");
when(goConfigDao.updateFullConfig(commandArgumentCaptor.capture())).thenReturn(null);
GoConfigService.XmlPartialSaver partialSaver = goConfigService.groupSaver("group_name");
GoConfigValidity validity = partialSaver.saveXml(groupXmlWithEntity(targetFile.getAbsolutePath()), "md5");
PipelineConfigs group = commandArgumentCaptor.getValue().configForEdit().findGroup("group_name");
PipelineConfig pipeline = group.findBy(new CaseInsensitiveString("pipeline1"));
assertThat(validity.isValid(), Matchers.is(true));
String entityValue = pipeline.getParams().getParamNamed("foo").getValue();
assertThat(entityValue, not(containsString("CONTENTS_OF_FILE")));
assertThat(entityValue, isEmptyString());
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnAllPipelinesForASuperAdmin.
@Test
public void shouldReturnAllPipelinesForASuperAdmin() throws Exception {
GoConfigMother configMother = new GoConfigMother();
BasicCruiseConfig config = GoConfigMother.defaultCruiseConfig();
GoConfigMother.enableSecurityWithPasswordFilePlugin(config);
GoConfigMother.addUserAsSuperAdmin(config, "superadmin");
PipelineConfig pipelineConfig = configMother.addPipelineWithGroup(config, "group1", "p1", "s1", "j1");
when(goConfigDao.loadForEditing()).thenReturn(config);
expectLoad(config);
List<PipelineConfig> pipelines = goConfigService.getAllPipelineConfigsForEditForUser(new Username("superadmin"));
assertThat(pipelines, contains(pipelineConfig));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoDashboardServiceTest method shouldRemoveExistingPipelineEntryInCacheWhenPipelineConfigIsRemoved.
@Test
public void shouldRemoveExistingPipelineEntryInCacheWhenPipelineConfigIsRemoved() {
BasicCruiseConfig config = GoConfigMother.defaultCruiseConfig();
PipelineConfig pipelineConfig = new GoConfigMother().addPipeline(config, "pipeline1", "stage1", "job1");
config.findGroupOfPipeline(pipelineConfig).remove(pipelineConfig);
when(goConfigService.findGroupByPipeline(any())).thenReturn(null);
// simulate the event
service.updateCacheForPipeline(pipelineConfig);
verify(cache).remove(pipelineConfig.getName());
verify(dashboardCurrentStateLoader).clearEntryFor(pipelineConfig.getName());
verifyNoMoreInteractions(dashboardCurrentStateLoader);
}
Aggregations