use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldBeAbleToPersistAMaterialWithNullBooleans.
@Test
public void shouldBeAbleToPersistAMaterialWithNullBooleans() throws Exception {
P4Material p4Material = new P4Material("serverAndPort", "view");
MaterialInstance original = p4Material.createMaterialInstance();
repo.saveOrUpdate(original);
MaterialInstance loaded = repo.find(original.getId());
Material restored = loaded.toOldMaterial(null, null, null);
assertThat(restored, is(p4Material));
}
use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.
the class Materials method latestModification.
@TestOnly
public MaterialRevisions latestModification(File baseDir, final SubprocessExecutionContext execCtx) {
MaterialRevisions revisions = new MaterialRevisions();
for (Material material : this) {
List<Modification> modifications = new ArrayList<>();
if (material instanceof SvnMaterial) {
modifications = ((SvnMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof HgMaterial) {
modifications = ((HgMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof GitMaterial) {
modifications = ((GitMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof P4Material) {
modifications = ((P4Material) material).latestModification(baseDir, execCtx);
}
if (material instanceof TfsMaterial) {
modifications = ((TfsMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof DependencyMaterial) {
modifications = ((DependencyMaterial) material).latestModification(baseDir, execCtx);
}
revisions.addRevision(material, modifications);
}
return revisions;
}
use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials.
@Test
public void shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials() throws SQLException {
String p4view = "//depot/... //localhost/...";
Materials p4Materials = MaterialsMother.p4Materials(p4view);
P4Material p4Material = (P4Material) p4Materials.first();
p4Material.setUseTickets(true);
PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
pipelineConfig.setMaterialConfigs(p4Materials.convertToConfigs());
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
assertNotInserted(pipeline.getId());
savePipeline(pipeline);
Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
Materials materials = pipelineFromDB.getMaterials();
assertThat(materials.get(0), is(p4Material));
}
use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldFetchDetailsRelatedToP4.
@Test
public void shouldFetchDetailsRelatedToP4() {
P4Material material = new P4Material("localhost:1666", "view");
MaterialRevisions materialRevisions = saveModifications(material, 1);
Modifications modificationList = materialRevisions.getModifications(material);
List<Modification> modifications = repo.getLatestModificationForEachMaterial();
assertThat(modifications.size(), is(1));
assertModificationAreEqual(modifications.get(0), modificationList.get(0));
MaterialInstance instance = modifications.get(0).getMaterialInstance();
assertThat(instance, instanceOf(P4MaterialInstance.class));
assertThat(instance.getFingerprint(), is(material.getFingerprint()));
assertThat(instance.getUrl(), is(material.getUrl()));
assertThat(instance.getUsername(), is(material.getUserName()));
assertThat(instance.getView(), is(material.getView()));
assertThat(instance.getUseTickets(), is(material.getUseTickets()));
}
use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.
the class MaterialsMother method p4Material.
public static P4Material p4Material(String serverAndPort, String userName, String password, String view, boolean useTickets) {
final P4Material material = new P4Material(serverAndPort, view, userName);
material.setAutoUpdate(true);
material.setPassword(password);
material.setUseTickets(useTickets);
return material;
}
Aggregations