use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldHandleNoModificationExceptionThrownByAutoBuild.
@Test
public void shouldHandleNoModificationExceptionThrownByAutoBuild() {
String pipelineName = "pipeline";
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
PipelineConfig config = PipelineConfigMother.pipelineConfig(pipelineName);
Material svnMaterial = MaterialsMother.defaultMaterials().get(0);
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("up"), new CaseInsensitiveString("s1"));
config.materialConfigs().clear();
config.addMaterialConfig(svnMaterial.config());
config.addMaterialConfig(dependencyMaterial.config());
when(pipelineService.getRevisionsBasedOnDependencies(Matchers.<MaterialRevisions>any(), Matchers.<BasicCruiseConfig>any(), Matchers.<CaseInsensitiveString>any())).thenThrow(new NoModificationsPresentForDependentMaterialException("P/1/S/1"));
when(pipelineScheduleQueue.mostRecentScheduled(pipelineName)).thenReturn(BuildCause.createNeverRun());
Modification modification = ModificationsMother.checkinWithComment("r", "c", new Date(), "f1");
when(materialRepository.findLatestModification(svnMaterial)).thenReturn(ModificationsMother.createSvnMaterialWithMultipleRevisions(1, modification));
when(materialRepository.findLatestModification(dependencyMaterial)).thenReturn(new MaterialRevisions(ModificationsMother.changedDependencyMaterialRevision("up", 1, "1", "s", 1, new Date())));
when(specificMaterialRevisionFactory.create(Matchers.<String>any(), Matchers.<Map<String, String>>any())).thenReturn(MaterialRevisions.EMPTY);
when(goConfigService.upstreamDependencyGraphOf(Matchers.<String>any(), Matchers.<BasicCruiseConfig>any())).thenReturn(new PipelineConfigDependencyGraph(config));
MaterialConfigs knownMaterialConfigs = new MaterialConfigs(svnMaterial.config(), dependencyMaterial.config());
Materials materials = new Materials(svnMaterial, dependencyMaterial);
when(materialConfigConverter.toMaterials(config.materialConfigs())).thenReturn(materials);
when(materialExpansionService.expandMaterialConfigsForScheduling(config.materialConfigs())).thenReturn(knownMaterialConfigs);
when(materialConfigConverter.toMaterials(knownMaterialConfigs)).thenReturn(materials);
AutoBuild autoBuild = new AutoBuild(goConfigService, pipelineService, pipelineName, new SystemEnvironment(), null, mockServerHealthService);
ServerHealthState serverHealthState = buildCauseProducerService.newProduceBuildCause(config, autoBuild, result, 12345);
assertThat(serverHealthState.isSuccess(), is(true));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldScheduleAfterAllMaterialsAreUpdated.
@Test
public void shouldScheduleAfterAllMaterialsAreUpdated() throws Exception {
HgMaterial hgMaterial = new HgMaterial("url", null);
HgMaterialConfig hgMaterialConfig = new HgMaterialConfig("url", null);
SvnMaterial svnMaterial = new SvnMaterial("url", null, null, false);
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig("url", null, null, false);
pipelineConfig.addMaterialConfig(hgMaterialConfig);
pipelineConfig.addMaterialConfig(svnMaterialConfig);
GoConfigService service = mock(GoConfigService.class);
when(service.pipelineConfigNamed(pipelineConfig.name())).thenReturn(pipelineConfig);
when(materialConfigConverter.toMaterial(hgMaterialConfig)).thenReturn(hgMaterial);
when(materialConfigConverter.toMaterial(svnMaterialConfig)).thenReturn(svnMaterial);
MaterialUpdateStatusNotifier notifier = new MaterialUpdateStatusNotifier(mock(MaterialUpdateCompletedTopic.class));
buildCauseProducerService = spy(createBuildCauseProducerService(notifier));
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(), new ServerHealthStateOperationResult());
final HashMap<String, String> stringStringHashMap = new HashMap<>();
doReturn(ServerHealthState.success(healthStateType)).when(buildCauseProducerService).newProduceBuildCause(eq(pipelineConfig), any(ManualBuild.class), new ScheduleOptions(eq(EMPTY_REVISIONS), stringStringHashMap, new HashMap<>()), any(ServerHealthStateOperationResult.class), eq(12345L));
assertThat(notifier.hasListenerFor(pipelineConfig), is(true));
notifier.onMessage(new MaterialUpdateSuccessfulMessage(hgMaterial, 1111L));
assertThat(notifier.hasListenerFor(pipelineConfig), is(true));
notifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 2222L));
assertThat(notifier.hasListenerFor(pipelineConfig), is(false));
verify(buildCauseProducerService).newProduceBuildCause(eq(pipelineConfig), any(ManualBuild.class), eq(new ScheduleOptions()), any(ServerHealthStateOperationResult.class), eq(2222L));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class EnvironmentVariableContextTest method shouldPopulateEnvironmentForMaterialUsingDest.
@Test
public void shouldPopulateEnvironmentForMaterialUsingDest() {
SvnMaterial svn = MaterialsMother.svnMaterial();
svn.setFolder("svn-dir");
MaterialRevision revision = new MaterialRevision(svn, ModificationsMother.oneModifiedFile("revision1"));
MaterialRevisions materialRevisions = new MaterialRevisions(revision);
EnvironmentVariableContext context = new EnvironmentVariableContext();
context.setProperty("GO_SERVER_URL", SystemEnvironment.getProperty("serviceUrl"), false);
jobIdentifier().populateEnvironmentVariables(context);
materialRevisions.populateEnvironmentVariables(context, WORKING_DIR);
assertThat(context.getProperty("GO_REVISION_SVN_DIR"), is("revision1"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevision.
@Test
public void shouldGetLatestRevision() {
SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), null);
SvnMaterial svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
final Materials materials = new Materials(svn, svnExt);
final MaterialRevisions materialRevisions = materials.latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
assertThat(materialRevisions.numberOfRevisions(), is(2));
MaterialRevision main = materialRevisions.getRevisions().get(0);
assertThat(main.getMaterial(), is(svn));
assertThat(main.getModifications().size(), is(1));
assertThat(main.getRevision().getRevision(), is("5"));
MaterialRevision external = materialRevisions.getRevisions().get(1);
assertThat(external.getMaterial(), is(svnExt));
assertThat(external.getRevision().getRevision(), is("4"));
assertThat(external.getModifications().size(), is(1));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevisionFromExpandedSvnExternalRepository.
@Test
public void shouldGetLatestRevisionFromExpandedSvnExternalRepository() {
MaterialRevisions materialRevisions = new MaterialRevisions();
Material svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
List<Modification> modifications = ((SvnMaterial) svnExt).latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
materialRevisions.addRevision(svnExt, modifications);
assertThat(materialRevisions.numberOfRevisions(), is(1));
MaterialRevision materialRevision = materialRevisions.getRevisions().get(0);
assertThat(materialRevision.getMaterial(), is(svnExt));
assertThat(materialRevision.getRevision().getRevision(), is("4"));
}
Aggregations