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();
}
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));
}
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"));
}
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)));
}
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)));
}
Aggregations