Search in sources :

Example 96 with Material

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

the class SCMMaterialSourceTest method shouldReloadSchedulableMaterialsOnConfigRepoChange.

@Test
public void shouldReloadSchedulableMaterialsOnConfigRepoChange() {
    Set<MaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config(), gitMaterial.config()));
    when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
    when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial, gitMaterial)));
    when(serverHealthService.logs()).thenReturn(new ServerHealthStates());
    source.onEntityConfigChange(mock(ConfigRepoConfig.class));
    Set<Material> materials = source.materialsForUpdate();
    assertThat(materials.size(), is(2));
    assertTrue(materials.contains(svnMaterial));
    assertTrue(materials.contains(gitMaterial));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) Material(com.thoughtworks.go.domain.materials.Material) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 97 with Material

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

the class MaterialUpdateStatusNotifierTest method shouldNotifyListenerWhenItsMaterialIsUpdated.

@Test
public void shouldNotifyListenerWhenItsMaterialIsUpdated() throws Exception {
    PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("config"), new MaterialConfigs());
    Material material = new HgMaterial("url", null);
    pipelineConfig.addMaterialConfig(material.config());
    MaterialUpdateStatusListener mockStatusListener = Mockito.mock(MaterialUpdateStatusListener.class);
    when(mockStatusListener.isListeningFor(material)).thenReturn(true);
    materialUpdateStatusNotifier.registerListenerFor(pipelineConfig, mockStatusListener);
    materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(material, 123));
    Mockito.verify(mockStatusListener).onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material, 123));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 98 with Material

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

the class GitPostCommitHookImplementerTest method shouldQueryOnlyGitMaterialsWhilePruning.

@Test
public void shouldQueryOnlyGitMaterialsWhilePruning() throws Exception {
    SvnMaterial material1 = mock(SvnMaterial.class);
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    HashMap params = new HashMap();
    params.put(GitPostCommitHookImplementer.REPO_URL_PARAM_KEY, "https://machine.local.git");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.jupiter.api.Test)

Example 99 with Material

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

the class GitPostCommitHookImplementerTest method shouldReturnEmptyListIfParamHasNoValueForRepoURL.

@Test
public void shouldReturnEmptyListIfParamHasNoValueForRepoURL() throws Exception {
    GitMaterial material1 = mock(GitMaterial.class);
    when(material1.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    HashMap params = new HashMap();
    params.put(GitPostCommitHookImplementer.REPO_URL_PARAM_KEY, "");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.jupiter.api.Test)

Example 100 with Material

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

the class PluggableSCMPostCommitHookImplementerTest method shouldReturnEmptyListIfNoMatchingMaterialFound.

@Test
public void shouldReturnEmptyListIfNoMatchingMaterialFound() throws Exception {
    PluggableSCMMaterial material1 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-1", null, null));
    PluggableSCMMaterial material2 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-2", null, null));
    Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2));
    Map params = new HashMap();
    params.put(PluggableSCMPostCommitHookImplementer.SCM_NAME, "unknown-scm-name");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Material(com.thoughtworks.go.domain.materials.Material) 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