use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method setup.
@Before
public void setup() throws Exception {
diskSpaceSimulator = new DiskSpaceSimulator();
hgRepo = new HgTestRepo("testHgRepo", temporaryFolder);
dbHelper.onSetUp();
configHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
materialConfig = hgRepo.materialConfig();
configHelper.addConfigRepo(new ConfigRepoConfig(materialConfig, "gocd-xml"));
logger = mock(MDUPerformanceLogger.class);
TestingEmailSender emailSender = new TestingEmailSender();
SystemDiskSpaceChecker mockDiskSpaceChecker = Mockito.mock(SystemDiskSpaceChecker.class);
StageService stageService = mock(StageService.class);
ConfigDbStateRepository configDbStateRepository = mock(ConfigDbStateRepository.class);
goDiskSpaceMonitor = new GoDiskSpaceMonitor(goConfigService, systemEnvironment, serverHealthService, emailSender, mockDiskSpaceChecker, mock(ArtifactsService.class), stageService, configDbStateRepository);
goDiskSpaceMonitor.initialize();
worker = new MaterialUpdateListener(configTopic, materialDatabaseUpdater, logger, goDiskSpaceMonitor);
xmlWriter = new MagicalGoConfigXmlWriter(configCache, ConfigElementImplementationRegistryMother.withNoPlugins());
configTestRepo = new ConfigTestRepo(hgRepo, xmlWriter);
this.material = (HgMaterial) materialConfigConverter.toMaterial(materialConfig);
pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
pipelineConfig.materialConfigs().clear();
pipelineConfig.materialConfigs().add(materialConfig);
PIPELINE_NAME = CaseInsensitiveString.str(pipelineConfig.name());
configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
pipelineConfig = goConfigService.pipelineConfigNamed(pipelineConfig.name());
pipelineScheduleQueue.clear();
// check test setup
Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs());
MaterialRevisions peggedRevisions = new MaterialRevisions();
firstRevisions = materialChecker.findLatestRevisions(peggedRevisions, materials);
assertThat(firstRevisions.isMissingModifications(), is(false));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal.
@Test
public void shouldCreateBuildCauseWithModificationsForSvnRepoWithExternal() throws Exception {
SvnTestRepoWithExternal repo = new SvnTestRepoWithExternal(temporaryFolder);
repositoryForMaterial(repo);
prepareAPipelineWithHistory();
checkInFiles("foo");
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
materialDatabaseUpdater.updateMaterial(svnMaterial);
buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
assertThat(result.canContinue(), is(true));
BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(CaseInsensitiveString.str(mingleConfig.name()));
MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
assertThat(materialRevisions.getRevisions().size(), is(2));
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(2));
assertThat(materials.get(0), is(svnMaterial));
SvnMaterial external = (SvnMaterial) materials.get(1);
assertThat(external.getUrl(), is(repo.externalRepositoryUrl()));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationSvnTest method shouldCreateBuildCauseWithModifications.
@Test
public void shouldCreateBuildCauseWithModifications() throws Exception {
repositoryForMaterial(new SvnTestRepo(temporaryFolder));
prepareAPipelineWithHistory();
checkInFiles("foo");
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
materialDatabaseUpdater.updateMaterial(svnMaterial);
buildCauseProducerService.autoSchedulePipeline(CaseInsensitiveString.str(mingleConfig.name()), result, 123);
assertThat(result.canContinue(), is(true));
BuildCause mingleBuildCause = pipelineScheduleQueue.toBeScheduled().get(CaseInsensitiveString.str(mingleConfig.name()));
MaterialRevisions materialRevisions = mingleBuildCause.getMaterialRevisions();
assertThat(materialRevisions.getRevisions().size(), is(1));
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(1));
assertThat(materials.get(0), is(svnMaterial));
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldPersistMaterialsWithRealPassword.
@Test
public void shouldPersistMaterialsWithRealPassword() {
MaterialRevisions materialRevisions = new MaterialRevisions();
addRevision(materialRevisions, MaterialsMother.svnMaterial("http://username:password@localhost"));
addRevision(materialRevisions, MaterialsMother.hgMaterial("http://username:password@localhost"));
addRevision(materialRevisions, new GitMaterial("git://username:password@localhost"));
addRevision(materialRevisions, new P4Material("localhost:1666", "view"));
BuildCause buildCause = BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS);
Pipeline pipeline = new Pipeline("Test", buildCause);
save(pipeline);
Pipeline loaded = pipelineDao.mostRecentPipeline("Test");
Materials materials = loaded.getMaterials();
for (Material material : materials) {
assertThat(((ScmMaterial) material).getUrl(), not(containsString("******")));
}
}
use of com.thoughtworks.go.config.materials.Materials in project gocd by gocd.
the class MaterialRevisionBuilder method depInstance.
public Tuple depInstance(String pipelineName, int counter, Date modifiedTime, Tuple... buildCause) {
String key = key(pipelineName, counter, modifiedTime);
if (!instanceToRevision.containsKey(key)) {
if (buildCause.length == 0) {
throw new RuntimeException("Cannot create instance without a buildcause. You can retrive it without buildcause once it has been created");
}
DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(STAGE_NAME));
DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, counter, "label", STAGE_NAME, 1);
instanceToRevision.put(key, revision.convert(material, modifiedTime));
final long id = getNextId();
org.mockito.Mockito.when(pipelineDao.findPipelineByNameAndCounter(pipelineName, counter)).thenReturn(pipeline(id));
org.mockito.Mockito.when(materialRepository.findMaterialRevisionsForPipeline(id)).thenReturn(buildCauseOfThisPipeline(buildCause));
}
MaterialRevision materialRevision = instanceToRevision.get(key);
Materials materials = new Materials();
for (MaterialRevision revision : buildCauseOfThisPipeline(buildCause)) {
materials.add(revision.getMaterial());
}
PipelineConfig config = new PipelineConfig(new CaseInsensitiveString(pipelineName), materials.convertToConfigs(), new StageConfig(new CaseInsensitiveString(STAGE_NAME), new JobConfigs()));
return new Tuple(new PipelineConfigDependencyGraph(config, dependencyGraphsFor(buildCause)), materialRevision);
}
Aggregations