Search in sources :

Example 56 with Material

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

the class PluggableSCMPostCommitHookImplementerTest method shouldReturnEmptyListIfParamIsMissingForSCMName.

@Test
public void shouldReturnEmptyListIfParamIsMissingForSCMName() throws Exception {
    PluggableSCMMaterial material1 = mock(PluggableSCMMaterial.class);
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    Set<Material> actual = implementer.prune(materials, new HashMap());
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
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.Test)

Example 57 with Material

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

the class PluggableSCMPostCommitHookImplementerTest method shouldQueryOnlyPluggableSCMMaterialsWhilePruning.

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

Example 58 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.Test)

Example 59 with Material

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

the class SvnPostCommitHookImplementerTest method shouldReturnEmptyListWhenUUIDIsNotPresent.

@Test
public void shouldReturnEmptyListWhenUUIDIsNotPresent() {
    final SvnMaterial svnMaterial1 = mock(SvnMaterial.class);
    final HashSet<Material> allMaterials = new HashSet<>();
    allMaterials.add(svnMaterial1);
    final SvnPostCommitHookImplementer spy = spy(implementer);
    final Set<Material> prunedList = spy.prune(allMaterials, new HashMap());
    assertThat(prunedList.size(), is(0));
    verify(spy, never()).isQualified(anyString(), any(SvnMaterial.class), any(HashMap.class));
}
Also used : HashMap(java.util.HashMap) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 60 with Material

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

the class SvnPostCommitHookImplementerTest method shouldCreateRemoteUrlToRemoteUUIDMap.

@Test
public void shouldCreateRemoteUrlToRemoteUUIDMap() {
    final SvnPostCommitHookImplementer spy = spy(implementer);
    final SvnCommand svnCommand = mock(SvnCommand.class);
    final Material svnMaterial1 = mock(SvnMaterial.class);
    final Material hgMaterial1 = mock(HgMaterial.class);
    final HashSet<Material> allMaterials = new HashSet<>(Arrays.asList(svnMaterial1, hgMaterial1));
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return svnCommand;
        }
    }).when(spy).getEmptySvnCommand();
    spy.createUrlToRemoteUUIDMap(allMaterials);
    verify(svnCommand).createUrlToRemoteUUIDMap(new HashSet<>(Arrays.asList((SvnMaterial) svnMaterial1)));
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Material (com.thoughtworks.go.domain.materials.Material)95 Test (org.junit.Test)59 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)39 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)39 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)23 Modification (com.thoughtworks.go.domain.materials.Modification)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)16 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)14 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)14 Materials (com.thoughtworks.go.config.materials.Materials)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)9 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)8 Date (java.util.Date)8 HashSet (java.util.HashSet)8 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7