use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class GitMaterialInstance method toOldMaterial.
@Override
public Material toOldMaterial(String name, String folder, String password) {
GitMaterial git = new GitMaterial(url, branch, folder);
setName(name, git);
git.setSubmoduleFolder(submoduleFolder);
git.setId(id);
return git;
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class PipelineSqlMapDaoCachingTest method shouldNotInvalidateCacheOfPipelineInstancesTriggeredWithMaterialRevision_WhenAPipelineInstanceIsCreatedWithDifferentMaterial.
@Test
public void shouldNotInvalidateCacheOfPipelineInstancesTriggeredWithMaterialRevision_WhenAPipelineInstanceIsCreatedWithDifferentMaterial() throws Exception {
GitMaterialInstance materialInstance = new GitMaterialInstance("url", "branch", "submodule", "flyweight");
String cacheKey = pipelineDao.cacheKeyForPipelineInstancesTriggeredWithDependencyMaterial("p1", materialInstance.getFingerprint(), "r1");
List<PipelineIdentifier> result = Arrays.asList(new PipelineIdentifier("p1", 1, "1"));
when(mockTemplate.queryForList(eq("pipelineInstancesTriggeredOffOfMaterialRevision"), anyString())).thenReturn(result);
List<PipelineIdentifier> actual = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial("p1", materialInstance, "r1");
assertThat(actual, Matchers.is(result));
assertThat(goCache.get(cacheKey), is(result));
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(new GitMaterial("url", "branch"), new Modification("user", "comment", "email", new Date(), "r2")));
Pipeline pipeline = new Pipeline("p1", BuildCause.createWithModifications(materialRevisions, ""));
pipelineDao.save(pipeline);
assertThat(goCache.get(cacheKey), is(result));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialCheckerTest method updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore.
@Test
public void updateChangedRevisionsShouldRetainLatestRevisionIfAllHaveBuiltBefore() {
CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
GitMaterial gitMaterial = new GitMaterial("git://foo");
BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(10L);
materialChecker.updateChangedRevisions(pipelineName, buildCause);
MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L), mod(9L), mod(8L))));
assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(false));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialCheckerTest method updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore.
@Test
public void updateChangedRevisionsShouldFilterRevisionsThatHaveBuiltBefore() {
CaseInsensitiveString pipelineName = new CaseInsensitiveString("pipelineName");
GitMaterial gitMaterial = new GitMaterial("git://foo");
BuildCause buildCause = BuildCause.createWithModifications(new MaterialRevisions(new MaterialRevision(gitMaterial, mod(10L), mod(9L), mod(8L))), "user");
when(materialRepository.latestModificationRunByPipeline(pipelineName, gitMaterial)).thenReturn(9L);
materialChecker.updateChangedRevisions(pipelineName, buildCause);
MaterialRevisions actualRevisions = buildCause.getMaterialRevisions();
assertThat(actualRevisions.getModifications(gitMaterial), is(new Modifications(mod(10L))));
assertThat(actualRevisions.findRevisionFor(gitMaterial).isChanged(), is(true));
}
use of com.thoughtworks.go.config.materials.git.GitMaterial in project gocd by gocd.
the class MaterialDatabaseUpdaterTest method shouldThrowExceptionWithLongDescriptionOfMaterialWhenUpdateFails.
@Test
public void shouldThrowExceptionWithLongDescriptionOfMaterialWhenUpdateFails() throws Exception {
Material material = new GitMaterial("url", "branch");
Exception exception = new RuntimeException("failed");
String message = "Modification check failed for material: " + material.getLongDescription();
ServerHealthState error = ServerHealthState.error(message, exception.getMessage(), HealthStateType.general(HealthStateScope.forMaterial(material)));
when(materialRepository.findMaterialInstance(material)).thenThrow(exception);
try {
materialDatabaseUpdater.updateMaterial(material);
fail("should have thrown exception");
} catch (Exception e) {
assertThat(e, is(exception));
}
verify(healthService).update(error);
}
Aggregations