Search in sources :

Example 26 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class MercurialPostCommitHookImplementerTest method shouldPruneMercurialMaterialsWhichMatchIncomingURL.

@Test
public void shouldPruneMercurialMaterialsWhichMatchIncomingURL() throws Exception {
    HgMaterial material1 = mock(HgMaterial.class);
    when(material1.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
    HgMaterial material2 = mock(HgMaterial.class);
    when(material2.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
    HgMaterial material3 = mock(HgMaterial.class);
    when(material3.getUrlArgument()).thenReturn(new UrlArgument("ssh://repo1.something.local"));
    GitMaterial material4 = mock(GitMaterial.class);
    when(material4.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
    Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2, material3, material4));
    Map params = new HashMap();
    params.put(MercurialPostCommitHookImplementer.REPO_URL_PARAM_KEY, "http://repo1.something.local");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(2));
    assertThat(actual, hasItem(material1));
    assertThat(actual, hasItem(material2));
    verify(material1).getUrlArgument();
    verify(material2).getUrlArgument();
    verify(material3).getUrlArgument();
    verify(material4, times(0)).getUrlArgument();
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 27 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class SvnPostCommitHookImplementerTest method shouldPruneListToGiveOutOnlySvnMaterials.

@Test
public void shouldPruneListToGiveOutOnlySvnMaterials() {
    final Material svnMaterial1 = mock(SvnMaterial.class);
    final Material svnMaterial2 = mock(SvnMaterial.class);
    final Material svnMaterial3 = mock(SvnMaterial.class);
    final Material hgMaterial = mock(HgMaterial.class);
    final Material gitMaterial = mock(GitMaterial.class);
    final Material p4Material = mock(P4Material.class);
    final Material tfsMaterial = mock(TfsMaterial.class);
    final Material dependencyMaterial = mock(DependencyMaterial.class);
    final HashSet<Material> allMaterials = new HashSet<>(Arrays.asList(svnMaterial1, svnMaterial2, svnMaterial3, gitMaterial, hgMaterial, p4Material, tfsMaterial, dependencyMaterial));
    final SvnPostCommitHookImplementer spy = spy(implementer);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return Boolean.TRUE;
        }
    }).when(spy).isQualified(anyString(), any(SvnMaterial.class), any(HashMap.class));
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return new HashMap();
        }
    }).when(spy).createUrlToRemoteUUIDMap(allMaterials);
    final HashMap params = new HashMap();
    params.put(SvnPostCommitHookImplementer.UUID, "some uuid");
    final Set<Material> prunedList = spy.prune(allMaterials, params);
    assertThat(prunedList.size(), is(3));
    assertThat(prunedList, hasItems(svnMaterial1, svnMaterial2, svnMaterial3));
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) HashMap(java.util.HashMap) InvocationOnMock(org.mockito.invocation.InvocationOnMock) 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 28 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class PipelineInstanceModelTest method shouldGetCurrentRevisionForMaterialName.

@Test
public void shouldGetCurrentRevisionForMaterialName() {
    HgMaterial material = MaterialsMother.hgMaterial();
    material.setName(new CaseInsensitiveString("foo"));
    assertThat(setUpModificationFor(material).getCurrentRevision(CaseInsensitiveString.str(material.getName())).getRevision(), is("a087402bd2a7828a130c1bdf43f2d9ef8f48fd46"));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 29 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class PipelineInstanceModelTest method shouldFallbackToPipelineFingerpringWhenGettingCurrentMaterialRevisionForMaterialIsNull.

@Test
public void shouldFallbackToPipelineFingerpringWhenGettingCurrentMaterialRevisionForMaterialIsNull() {
    MaterialRevisions revisions = new MaterialRevisions();
    HgMaterial material = MaterialsMother.hgMaterial();
    HgMaterial materialWithDifferentDest = MaterialsMother.hgMaterial();
    materialWithDifferentDest.setFolder("otherFolder");
    revisions.addRevision(material, HG_MATERIAL_MODIFICATION);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline("pipeline", -1, "label", BuildCause.createWithModifications(revisions, ""), new StageInstanceModels());
    assertThat(model.findCurrentMaterialRevisionForUI(materialWithDifferentDest.config()), is(revisions.getMaterialRevision(0)));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 30 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class PipelineInstanceModelTest method shouldGetLatestMaterialRevisionForMaterial.

@Test
public void shouldGetLatestMaterialRevisionForMaterial() {
    HgMaterial material = MaterialsMother.hgMaterial();
    assertThat(setUpModificationForHgMaterial().getLatestMaterialRevision(material.config()), is(new MaterialRevision(material, HG_MATERIAL_MODIFICATION)));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)121 Test (org.junit.Test)107 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)34 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)29 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)23 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)15 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)10 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 Date (java.util.Date)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)9 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)8 Pagination (com.thoughtworks.go.server.util.Pagination)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)6 Modification (com.thoughtworks.go.domain.materials.Modification)6 File (java.io.File)6