Search in sources :

Example 1 with HgMaterial

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

the class BuildCauseProducerServiceTest method manualTrigger_shouldNotUpdatePipelineConfigWhenConfigRepoIsNotInMaterials.

@Test
public void manualTrigger_shouldNotUpdatePipelineConfigWhenConfigRepoIsNotInMaterials() {
    HgMaterial material1 = new HgMaterial("url", null);
    HgMaterialConfig materialConfig1 = new HgMaterialConfig("url", null);
    HgMaterialConfig materialConfig2 = new HgMaterialConfig("url2", null);
    pipelineConfig.addMaterialConfig(materialConfig1);
    pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig2, "plug"), "revision1"));
    when(materialConfigConverter.toMaterial(materialConfig1)).thenReturn(material1);
    buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(new HashMap<>(), new HashMap<>(), new HashMap<>()), new ServerHealthStateOperationResult());
    verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
    MaterialUpdateStatusListener statusListener = extractMaterialListenerInstanceFromRegisterCall();
    statusListener.onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material1, 0));
    verify(mockMaterialUpdateStatusNotifier).removeListenerFor(pipelineConfig);
    verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
}
Also used : MaterialUpdateStatusListener(com.thoughtworks.go.server.materials.MaterialUpdateStatusListener) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) HashMap(java.util.HashMap) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) MaterialUpdateSuccessfulMessage(com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage) Test(org.junit.Test)

Example 2 with HgMaterial

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

the class MaterialsTest method shouldReturnMaterialBasedOnPiplineUniqueFingerPrint.

@Test
public void shouldReturnMaterialBasedOnPiplineUniqueFingerPrint() {
    Materials materials = new Materials();
    HgMaterial expectedMaterial = MaterialsMother.hgMaterial();
    materials.add(expectedMaterial);
    materials.add(MaterialsMother.gitMaterial("url"));
    materials.add(MaterialsMother.svnMaterial("url", "folder"));
    Material actualMaterial = materials.getByFingerPrint(expectedMaterial.getPipelineUniqueFingerprint());
    assertThat(actualMaterial, is(expectedMaterial));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) 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) Test(org.junit.Test)

Example 3 with HgMaterial

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

the class MaterialsTest method shouldGetPluggableSCMMaterial_byFolder.

@Test
public void shouldGetPluggableSCMMaterial_byFolder() {
    Materials materials = new Materials();
    PluggableSCMMaterial material1 = new PluggableSCMMaterial("scm-id");
    material1.setFolder("folder");
    Material material2 = new HgMaterial("", "folder");
    materials.add(material1);
    materials.add(material2);
    assertThat(materials.byFolder("folder"), is(material1));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) 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) Test(org.junit.Test)

Example 4 with HgMaterial

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

the class MaterialRepositoryWithH2IntegrationTest method materialFingerprintShouldUseTheHashAlgoritmInMigration47.

@Test
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void materialFingerprintShouldUseTheHashAlgoritmInMigration47() throws Exception {
    final HgMaterial material = new HgMaterial("url", null);
    byte[] fingerprint = (byte[]) repo.getHibernateTemplate().execute(new HibernateCallback() {

        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            String pattern = format("'type=%s%surl=%s'", material.getType(), AbstractMaterial.FINGERPRINT_DELIMITER, material.getUrl());
            SQLQuery query = session.createSQLQuery(format("CALL HASH('SHA256', STRINGTOUTF8(%s), 1)", pattern));
            return query.uniqueResult();
        }
    });
    assertThat(Hex.encodeHexString(fingerprint), is(material.getFingerprint()));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HibernateCallback(org.springframework.orm.hibernate3.HibernateCallback) Matchers.containsString(org.hamcrest.Matchers.containsString) SQLQuery(org.hibernate.SQLQuery) Session(org.hibernate.Session) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 5 with HgMaterial

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

the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.

@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
    HgMaterial hgMaterial = hgRepo.material();
    SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
    GitMaterial gitMaterial = gitRepo.createMaterial();
    Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
    MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
    assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
    assertThat(revisions.getMaterialRevision(2).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
    assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)136 Test (org.junit.jupiter.api.Test)114 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)41 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)27 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)25 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)22 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)20 Material (com.thoughtworks.go.domain.materials.Material)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)14 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)13 Date (java.util.Date)11 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)8 Modification (com.thoughtworks.go.domain.materials.Modification)7 Pagination (com.thoughtworks.go.server.util.Pagination)7 File (java.io.File)7 Materials (com.thoughtworks.go.config.materials.Materials)6