Search in sources :

Example 1 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class BuildCause method materials.

public Materials materials() {
    final List<Material> materials = new ArrayList<>();
    materialRevisions.accept(new ModificationVisitorAdapter() {

        public void visit(Material material, Revision revision) {
            materials.add(material);
        }
    });
    return new Materials(materials);
}
Also used : MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Revision(com.thoughtworks.go.domain.materials.Revision) Materials(com.thoughtworks.go.config.materials.Materials) ArrayList(java.util.ArrayList) Material(com.thoughtworks.go.domain.materials.Material) ModificationVisitorAdapter(com.thoughtworks.go.domain.ModificationVisitorAdapter)

Example 2 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class ConfigMaterialUpdaterTest method SetUp.

@Before
public void SetUp() {
    repoConfigDataSource = mock(GoRepoConfigDataSource.class);
    materialChecker = mock(MaterialChecker.class);
    materialRepository = mock(MaterialRepository.class);
    configCompleted = mock(ConfigMaterialUpdateCompletedTopic.class);
    topic = mock(MaterialUpdateCompletedTopic.class);
    materialService = mock(MaterialService.class);
    material = new SvnMaterial("url", "tom", "pass", false);
    when(materialRepository.folderFor(material)).thenReturn(folder);
    poller = mock(MaterialPoller.class);
    when(materialService.getPollerImplementation(any(Material.class))).thenReturn(poller);
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "1");
    mods = revisions(material, svnModification);
    when(materialRepository.findLatestModification(material)).thenReturn(mods);
    configUpdater = new ConfigMaterialUpdater(repoConfigDataSource, materialRepository, materialChecker, configCompleted, topic, materialService, new TestSubprocessExecutionContext());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Date(java.util.Date) GoRepoConfigDataSource(com.thoughtworks.go.config.GoRepoConfigDataSource) MaterialService(com.thoughtworks.go.server.service.MaterialService) MaterialPoller(com.thoughtworks.go.server.service.materials.MaterialPoller) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) Before(org.junit.Before)

Example 3 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class MaterialUpdateServiceTest method shouldReturnImplementerOfSvnPostCommitHookAndPerformMaterialUpdate_WhenInvokingPostCommitHookMaterialUpdate.

@Test
public void shouldReturnImplementerOfSvnPostCommitHookAndPerformMaterialUpdate_WhenInvokingPostCommitHookMaterialUpdate() {
    final HashMap params = new HashMap();
    params.put(MaterialUpdateService.TYPE, "svn");
    when(goConfigService.isUserAdmin(username)).thenReturn(true);
    final CruiseConfig cruiseConfig = new BasicCruiseConfig(PipelineConfigMother.createGroup("groupName", "pipeline1", "pipeline2"));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(postCommitHookMaterialType.toType("svn")).thenReturn(validMaterialType);
    final PostCommitHookImplementer svnPostCommitHookImplementer = mock(PostCommitHookImplementer.class);
    final Material svnMaterial = mock(Material.class);
    when(svnPostCommitHookImplementer.prune(anySet(), eq(params))).thenReturn(new HashSet(Arrays.asList(svnMaterial)));
    when(validMaterialType.getImplementer()).thenReturn(svnPostCommitHookImplementer);
    service.notifyMaterialsForUpdate(username, params, result);
    verify(svnPostCommitHookImplementer).prune(anySet(), eq(params));
    Mockito.verify(queue, times(1)).post(matchMaterialUpdateMessage(svnMaterial));
    HttpLocalizedOperationResult acceptedResult = new HttpLocalizedOperationResult();
    acceptedResult.accepted(LocalizedMessage.string("MATERIAL_SCHEDULE_NOTIFICATION_ACCEPTED"));
    assertThat(result, is(acceptedResult));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) PostCommitHookImplementer(com.thoughtworks.go.server.materials.postcommit.PostCommitHookImplementer) Test(org.junit.Test)

Example 4 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class MaterialUpdateServiceTest method shouldReturn404WhenThereAreNoMaterialsToSchedule_WhenInvokingPostCommitHookMaterialUpdate.

@Test
public void shouldReturn404WhenThereAreNoMaterialsToSchedule_WhenInvokingPostCommitHookMaterialUpdate() {
    when(goConfigService.isUserAdmin(username)).thenReturn(true);
    PostCommitHookMaterialType materialType = mock(PostCommitHookMaterialType.class);
    when(postCommitHookMaterialType.toType("type")).thenReturn(materialType);
    PostCommitHookImplementer hookImplementer = mock(PostCommitHookImplementer.class);
    when(materialType.getImplementer()).thenReturn(hookImplementer);
    when(materialType.isKnown()).thenReturn(true);
    CruiseConfig config = mock(BasicCruiseConfig.class);
    when(goConfigService.currentCruiseConfig()).thenReturn(config);
    when(config.getGroups()).thenReturn(new PipelineGroups());
    when(hookImplementer.prune(anySet(), anyMap())).thenReturn(new HashSet<Material>());
    final HashMap params = new HashMap();
    params.put(MaterialUpdateService.TYPE, "type");
    service.notifyMaterialsForUpdate(username, params, result);
    HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    operationResult.notFound(LocalizedMessage.string("MATERIAL_SUITABLE_FOR_NOTIFICATION_NOT_FOUND"), HealthStateType.general(HealthStateScope.GLOBAL));
    assertThat(result, is(operationResult));
    verify(hookImplementer).prune(anySet(), anyMap());
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) PostCommitHookImplementer(com.thoughtworks.go.server.materials.postcommit.PostCommitHookImplementer) PostCommitHookMaterialType(com.thoughtworks.go.server.materials.postcommit.PostCommitHookMaterialType) Test(org.junit.Test)

Example 5 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class ValueStreamMapService method traverseUpstream.

private void traverseUpstream(String pipelineName, BuildCause buildCause, ValueStreamMap graph, List<MaterialRevision> visitedNodes) {
    for (MaterialRevision materialRevision : buildCause.getMaterialRevisions()) {
        Material material = materialRevision.getMaterial();
        if (material instanceof DependencyMaterial) {
            String upstreamPipeline = ((DependencyMaterial) material).getPipelineName().toString();
            DependencyMaterialRevision revision = (DependencyMaterialRevision) materialRevision.getRevision();
            graph.addUpstreamNode(new PipelineDependencyNode(upstreamPipeline, upstreamPipeline), new PipelineRevision(revision.getPipelineName(), revision.getPipelineCounter(), revision.getPipelineLabel()), pipelineName);
            if (visitedNodes.contains(materialRevision)) {
                continue;
            }
            visitedNodes.add(materialRevision);
            DependencyMaterialRevision dmrOfUpstreamPipeline = buildCause.getMaterialRevisions().findDependencyMaterialRevision(upstreamPipeline);
            BuildCause buildCauseForUpstreamPipeline = pipelineService.buildCauseFor(dmrOfUpstreamPipeline.getPipelineName(), dmrOfUpstreamPipeline.getPipelineCounter());
            traverseUpstream(upstreamPipeline, buildCauseForUpstreamPipeline, graph, visitedNodes);
        } else {
            graph.addUpstreamMaterialNode(new SCMDependencyNode(material.getFingerprint(), material.getUriForDisplay(), materialRevision.getMaterialType()), material.getName(), pipelineName, materialRevision);
        }
    }
}
Also used : Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

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