use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class DependencyMaterialUpdateNotifierTest method shouldRetryUpdatingMaterialsPreviouslyInProgress_OnMaterialUpdate.
@Test
public void shouldRetryUpdatingMaterialsPreviouslyInProgress_OnMaterialUpdate() {
Stage stage = StageMother.passedStageInstance("Stage1", "plan", "Pipeline1");
DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial(stage.getIdentifier().getPipelineName(), stage.getName());
Set<DependencyMaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList((DependencyMaterialConfig) dependencyMaterial.config()));
when(goConfigService.getSchedulableDependencyMaterials()).thenReturn(schedulableMaterialConfigs);
when(materialConfigConverter.toMaterial(dependencyMaterial.config())).thenReturn(dependencyMaterial);
when(materialUpdateService.updateMaterial(dependencyMaterial)).thenReturn(true, false);
notifier = new DependencyMaterialUpdateNotifier(goConfigService, materialConfigConverter, materialUpdateService, serverHealthService);
notifier.initialize();
notifier.stageStatusChanged(stage);
notifier.onMaterialUpdate(dependencyMaterial);
verify(materialUpdateService, atMost(3)).updateMaterial(dependencyMaterial);
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialCheckerTest method shouldThrowExceptionIfSpecifiedRevisionDoesNotExist.
@Test
public void shouldThrowExceptionIfSpecifiedRevisionDoesNotExist() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
Mockito.when(materialRepository.findModificationWithRevision(dependencyMaterial, "pipeline-name/500/stage-name/0")).thenReturn(null);
try {
materialChecker.findSpecificRevision(dependencyMaterial, "pipeline-name/500/stage-name/0");
fail("Should not be able to find revision");
} catch (Exception expected) {
assertThat(expected.getMessage(), is(format("Unable to find revision [pipeline-name/500/stage-name/0] for material [%s]", dependencyMaterial)));
}
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialCheckerTest method shouldThrowExceptionIfRevisionIsNotSpecified.
@Test
public void shouldThrowExceptionIfRevisionIsNotSpecified() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
try {
materialChecker.findSpecificRevision(dependencyMaterial, "");
fail("Should not be able to empty revision");
} catch (Exception expected) {
assertThat(expected.getMessage(), is(format("Revision was not specified for material [%s]", dependencyMaterial)));
}
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialCheckerTest method shouldSkipLatestRevisionsForMaterialsThatWereAlreadyChecked.
@Test
public void shouldSkipLatestRevisionsForMaterialsThatWereAlreadyChecked() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
SvnMaterial svnMaterial = new SvnMaterial("svnUrl", null, null, false);
Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
Modification dependencyModification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0");
Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "1");
Mockito.when(materialRepository.findLatestModification(svnMaterial)).thenReturn(revisions(dependencyMaterial, svnModification));
materialChecker.findLatestRevisions(new MaterialRevisions(new MaterialRevision(dependencyMaterial, dependencyModification)), new Materials(dependencyMaterial, svnMaterial));
Mockito.verify(materialRepository, never()).findLatestModification(dependencyMaterial);
Mockito.verify(materialRepository).findLatestModification(svnMaterial);
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialCheckerTest method shouldFindSpecificRevisionForDependentPipeline.
@Test
public void shouldFindSpecificRevisionForDependentPipeline() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
Modification modification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1/stage-name/0");
Mockito.when(materialRepository.findModificationWithRevision(dependencyMaterial, "pipeline-name/1/stage-name/0")).thenReturn(modification);
MaterialRevision actualRevision = materialChecker.findSpecificRevision(dependencyMaterial, "pipeline-name/1/stage-name/0");
assertThat(actualRevision.getModifications().size(), is(1));
assertThat(actualRevision.getModification(0).getModifiedTime(), is(passedStage.completedDate()));
assertThat(actualRevision.getModification(0).getRevision(), is("pipeline-name/1/stage-name/0"));
}
Aggregations