Search in sources :

Example 36 with Material

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;
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) Material(com.thoughtworks.go.domain.materials.Material)

Example 37 with Material

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));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) ArrayList(java.util.ArrayList) Material(com.thoughtworks.go.domain.materials.Material) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.jupiter.api.Test)

Example 38 with Material

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);
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Material(com.thoughtworks.go.domain.materials.Material) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 39 with Material

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"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.jupiter.api.Test)

Example 40 with Material

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);
}
Also used : Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.jupiter.api.Test)

Aggregations

Material (com.thoughtworks.go.domain.materials.Material)122 Test (org.junit.jupiter.api.Test)72 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)47 Modification (com.thoughtworks.go.domain.materials.Modification)29 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)24 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)19 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)19 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)18 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)18 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)16 Materials (com.thoughtworks.go.config.materials.Materials)14 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)13 File (java.io.File)13 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)12 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)8