use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class ChangesetService method groupModsByMaterial.
Map<Material, Modifications> groupModsByMaterial(Collection<Modification> modifications) {
Map<Material, Modifications> grouped = new LinkedHashMap<>();
for (Modification modification : modifications) {
Material material = modification.getMaterialInstance().toOldMaterial(null, null, null);
Modifications mods = mapContainsMaterialWithFingerprint(grouped, material.getFingerprint());
if (mods == null) {
mods = new Modifications();
grouped.put(material, mods);
}
mods.add(modification);
}
return grouped;
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class LegacyMaterialCheckerTest method shouldGetModificationsSinceRevision.
@Test
public void shouldGetModificationsSinceRevision() {
Material material = mock(Material.class);
MaterialRevision materialRevision = mock(MaterialRevision.class);
Revision revision = mock(Revision.class);
List<Modification> modifications = new ArrayList<>();
when(materialRevision.getRevision()).thenReturn(revision);
when(materialService.modificationsSince(material, file, revision, null)).thenReturn(modifications);
List<Modification> actual = checker.findModificationsSince(file, material, materialRevision);
assertThat(actual, is(modifications));
}
use of com.thoughtworks.go.domain.materials.Material 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() + "\nAffected pipelines are blah.";
when(goConfigService.pipelinesWithMaterial(material.config().getFingerprint())).thenReturn(Collections.singletonList(new CaseInsensitiveString("blah")));
ServerHealthState error = ServerHealthState.errorWithHtml(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);
}
use of com.thoughtworks.go.domain.materials.Material 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"));
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class SvnMaterialTest method shouldNotBeEqualWhenUrlDifferent.
@Test
void shouldNotBeEqualWhenUrlDifferent() {
final Material material1 = MaterialsMother.defaultSvnMaterialsWithUrl("url1").get(0);
final Material material2 = MaterialsMother.defaultSvnMaterialsWithUrl("url2").get(0);
assertComplementaryEquals(material1, material2, false);
}
Aggregations