Search in sources :

Example 21 with ScmMaterial

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

the class MaterialRepositoryIntegrationTest method shouldMatchSearchStringInDecreasingOrder.

@Test
public void shouldMatchSearchStringInDecreasingOrder() throws Exception {
    ScmMaterial material = material();
    repo.saveOrUpdate(material.createMaterialInstance());
    MaterialRevision first = saveOneScmModification("40c95a3c41f54b5fb3107982cf2acd08783f102a", material, "pavan", "meet_you_in_hell.txt", "comment");
    MaterialRevision second = saveOneScmModification("c30c471137f31a4bf735f653f888e799f6deec04", material, "turn_her", "of_course_he_will_be_there_first.txt", "comment");
    List<MatchedRevision> revisions = repo.findRevisionsMatching(material.config(), "");
    assertThat(revisions.size(), is(2));
    assertMatchedRevision(revisions.get(0), second.getLatestShortRevision(), second.getLatestRevisionString(), "turn_her", second.getDateOfLatestModification(), "comment");
    assertMatchedRevision(revisions.get(1), first.getLatestShortRevision(), first.getLatestRevisionString(), "pavan", first.getDateOfLatestModification(), "comment");
}
Also used : ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Example 22 with ScmMaterial

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

the class MaterialRepositoryIntegrationTest method shouldCacheModificationsForMaterialCorrectly.

@Test
public void shouldCacheModificationsForMaterialCorrectly() throws Exception {
    final ScmMaterial material = material();
    MaterialInstance materialInstance = material.createMaterialInstance();
    repo.saveOrUpdate(materialInstance);
    saveOneScmModification("1", material, "user1", "1.txt", "comment1");
    saveOneScmModification("2", material, "user2", "2.txt", "comment2");
    saveOneScmModification("3", material, "user3", "3.txt", "comment3");
    saveOneScmModification("4", material, "user4", "4.txt", "comment4");
    saveOneScmModification("5", material, "user5", "5.txt", "comment5");
    Long totalCount = repo.getTotalModificationsFor(materialInstance);
    totalCount = (Long) goCache.get(repo.materialModificationCountKey(materialInstance));
    final Modification modOne = new Modification("user", "comment", "email@gmail.com", new Date(), "123");
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            MaterialInstance foo = repo.findOrCreateFrom(material);
            repo.saveModifications(foo, asList(modOne));
        }
    });
    totalCount = (Long) goCache.get(repo.materialModificationCountKey(materialInstance));
    assertThat(totalCount, is(nullValue()));
}
Also used : ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) TransactionStatus(org.springframework.transaction.TransactionStatus) PackageMaterialInstance(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance) PluggableSCMMaterialInstance(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance) SvnMaterialInstance(com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance) Date(java.util.Date) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Test(org.junit.Test)

Example 23 with ScmMaterial

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

the class MaterialRepositoryIntegrationTest method shouldFindLatestRevision.

@Test
public void shouldFindLatestRevision() throws Exception {
    ScmMaterial material = material();
    repo.saveOrUpdate(material.createMaterialInstance());
    MaterialRevision first = saveOneScmModification("40c95a3c41f54b5fb3107982cf2acd08783f102a", material, "pavan", "meet_you_in_hell.txt", "comment");
    MaterialRevision second = saveOneScmModification("c30c471137f31a4bf735f653f888e799f6deec04", material, "turn_her", "of_course_he_will_be_there_first.txt", "comment");
    MaterialRevisions materialRevisions = repo.findLatestModification(material);
    List<MaterialRevision> revisions = materialRevisions.getRevisions();
    assertThat(revisions.size(), is(1));
    MaterialRevision materialRevision = revisions.get(0);
    assertThat(materialRevision.getLatestRevisionString(), is(second.getLatestRevisionString()));
}
Also used : ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Example 24 with ScmMaterial

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

the class PipelineLabelTest method shouldTruncateMaterialRevision.

@Test
public void shouldTruncateMaterialRevision() throws Exception {
    PipelineLabel label = PipelineLabel.create("release-${svnMaterial}-${git[:6]}");
    MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
    ScmMaterial material = MaterialsMother.gitMaterial("");
    material.setName(new CaseInsensitiveString("git"));
    Modification modification = new Modification();
    modification.setRevision("8c8a273e12a45e57fed5ce978d830eb482f6f666");
    materialRevisions.addRevision(material, modification);
    label.updateLabel(materialRevisions.getNamedRevisions());
    assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision() + "-8c8a27"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 25 with ScmMaterial

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

the class PipelineLabelTest method shouldReplaceTheTemplateWithGitMaterialRevision.

@Test
public void shouldReplaceTheTemplateWithGitMaterialRevision() throws Exception {
    PipelineLabel label = PipelineLabel.create("release-${svnMaterial}-${git}");
    MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
    ScmMaterial material = MaterialsMother.gitMaterial("");
    material.setName(new CaseInsensitiveString("git"));
    Modification modification = new Modification();
    modification.setRevision("8c8a273e12a45e57fed5ce978d830eb482f6f666");
    materialRevisions.addRevision(material, modification);
    label.updateLabel(materialRevisions.getNamedRevisions());
    assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision() + "-8c8a273e12a45e57fed5ce978d830eb482f6f666"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)26 Test (org.junit.Test)24 Modification (com.thoughtworks.go.domain.materials.Modification)6 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)5 MaterialUpdateMessageMatcher.matchMaterialUpdateMessage (com.thoughtworks.go.helper.MaterialUpdateMessageMatcher.matchMaterialUpdateMessage)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 PackageMaterialInstance (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance)4 PluggableSCMMaterialInstance (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance)4 SvnMaterialInstance (com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance)4 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)3 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 RunIf (com.googlecode.junit.ext.RunIf)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 PipelineLabel (com.thoughtworks.go.domain.label.PipelineLabel)2 Material (com.thoughtworks.go.domain.materials.Material)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2