use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class BuildWorkTest method createBuildWorkWithJobPlan.
private void createBuildWorkWithJobPlan(JobPlan jobPlan) throws Exception {
CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(FileUtil.readToEnd(IOUtils.toInputStream(ConfigFileFixture.withJob(CMD_NOT_EXIST)))).config;
JobConfig jobConfig = cruiseConfig.jobConfigByName(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, true);
final Stage stage = StageMother.custom(STAGE_NAME, new JobInstance(JOB_PLAN_NAME));
BuildCause buildCause = BuildCause.createWithEmptyModifications();
final Pipeline pipeline = new Pipeline(PIPELINE_NAME, buildCause, stage);
List<Builder> builder = builderFactory.buildersForTasks(pipeline, jobConfig.getTasks(), resolver);
BuildAssignment buildAssignment = BuildAssignment.create(jobPlan, BuildCause.createWithEmptyModifications(), builder, pipeline.defaultWorkingFolder());
buildWork = new BuildWork(buildAssignment);
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class LongWorkCreator method getWork.
public Work getWork() {
try {
CruiseConfig config = GoConfigMother.pipelineHavingJob(PIPELINE_NAME, STAGE_NAME, JOB_PLAN_NAME, ARTIFACT_FILE.getAbsolutePath(), ARTIFACT_FOLDER.getAbsolutePath());
BuildCause buildCause = BuildCause.createWithEmptyModifications();
builder = new ArrayList<>();
builder.add(new SleepBuilder());
JobPlan instance = toBuildInstance(config);
BuildAssignment buildAssignment = BuildAssignment.create(instance, buildCause, builder, new File(CruiseConfig.WORKING_BASE_DIR + PIPELINE_NAME));
return new BuildWork(buildAssignment);
} catch (Exception e) {
throw bomb(e);
}
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class ServerConfigTest method shouldParseServerConfigWithMailhost.
@Test
public void shouldParseServerConfigWithMailhost() throws Exception {
String xml = "<mailhost hostname=\"smtp.company.com\" port=\"25\" " + "username=\"smtpuser\" password=\"password\" tls=\"true\" " + "from=\"cruise@me.com\" admin=\"jez@me.com\"/>";
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
CruiseConfig config = new MagicalGoConfigXmlLoader(new ConfigCache(), registry).loadConfigHolder(withServerConfig(xml)).config;
MailHost mailHost = config.server().mailHost();
assertThat(mailHost, is(new MailHost("smtp.company.com", 25, "smtpuser", "password", true, true, "cruise@me.com", "jez@me.com")));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class PipelineSqlMapDaoCachingTest method loadActivePipelines_shouldCacheResult.
@Test
public void loadActivePipelines_shouldCacheResult() {
final String pipelineName = "pipeline";
CruiseConfig mockCruiseConfig = mock(BasicCruiseConfig.class);
GoConfigDao mockconfigFileDao = mock(GoConfigDao.class);
when(mockconfigFileDao.load()).thenReturn(mockCruiseConfig);
when(mockCruiseConfig.getAllPipelineNames()).thenReturn(Arrays.asList(new CaseInsensitiveString(pipelineName)));
// need to mock configfileDao for this test
pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null, transactionSynchronizationManager, null, mockconfigFileDao, null, mock(SessionFactory.class));
pipelineDao.setSqlMapClientTemplate(mockTemplate);
PipelineInstanceModel pipeline = new PipelineInstanceModel(pipelineName, -2, "label", BuildCause.createManualForced(), new StageInstanceModels());
PipelineInstanceModels pims = PipelineInstanceModels.createPipelineInstanceModels(pipeline);
when(mockTemplate.queryForList("allActivePipelines")).thenReturn(pims);
when(mockTemplate.queryForObject(eq("getPipelineHistoryById"), any())).thenReturn(pipeline);
PipelineInstanceModels loaded;
loaded = pipelineDao.loadActivePipelines();
loaded = pipelineDao.loadActivePipelines();
assertNotSame(pipeline, loaded);
assertTrue(ToStringBuilder.reflectionToString(loaded) + " not equal to\n" + ToStringBuilder.reflectionToString(pipeline), EqualsBuilder.reflectionEquals(loaded, pims));
verify(mockTemplate, times(1)).queryForList("allActivePipelines");
verify(mockTemplate, times(1)).queryForObject(eq("getPipelineHistoryById"), any());
verify(mockconfigFileDao, times(2)).load();
verify(mockCruiseConfig, times(2)).getAllPipelineNames();
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class GoDashboardConfigChangeHandlerTest method shouldReplaceAllEntriesInCacheWithNewEntriesWhenTheWholeConfigHasChanged.
@Test
public void shouldReplaceAllEntriesInCacheWithNewEntriesWhenTheWholeConfigHasChanged() throws Exception {
CruiseConfig config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2");
handler.call(config);
verify(cacheUpdateService).updateCacheForAllPipelinesIn(config);
}
Aggregations