Search in sources :

Example 6 with ScmMaterial

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

the class MaterialUpdateServiceTest method shouldAllowPostCommitNotificationsToPassThroughToTheQueue_WhenTheSameMaterialIsNotCurrentlyInProgressAndMaterialIsAutoUpdateTrue.

@Test
public void shouldAllowPostCommitNotificationsToPassThroughToTheQueue_WhenTheSameMaterialIsNotCurrentlyInProgressAndMaterialIsAutoUpdateTrue() throws Exception {
    ScmMaterial material = mock(ScmMaterial.class);
    when(material.isAutoUpdate()).thenReturn(true);
    MaterialUpdateMessage message = new MaterialUpdateMessage(material, 0);
    doNothing().when(queue).post(message);
    // first call to the method
    service.updateMaterial(material);
    verify(queue, times(1)).post(message);
    verify(material, never()).isAutoUpdate();
}
Also used : MaterialUpdateMessageMatcher.matchMaterialUpdateMessage(com.thoughtworks.go.helper.MaterialUpdateMessageMatcher.matchMaterialUpdateMessage) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Example 7 with ScmMaterial

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

the class MaterialRepositoryIntegrationTest method shouldMatchSearchStringAcrossColumn.

@Test
public void shouldMatchSearchStringAcrossColumn() 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(), "pavan co");
    assertThat(revisions.size(), is(1));
    assertMatchedRevision(revisions.get(0), first.getLatestShortRevision(), first.getLatestRevisionString(), "pavan", first.getDateOfLatestModification(), "comment");
    revisions = repo.findRevisionsMatching(material.config(), "her co");
    assertThat(revisions.size(), is(1));
    assertMatchedRevision(revisions.get(0), second.getLatestShortRevision(), second.getLatestRevisionString(), "turn_her", second.getDateOfLatestModification(), "comment");
    revisions = repo.findRevisionsMatching(material.config(), "of_curs");
    assertThat(revisions.size(), is(0));
}
Also used : ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Example 8 with ScmMaterial

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

the class MaterialRepositoryIntegrationTest method shouldConsiderFieldToBeEmptyWhenRevisionOrUsernameOrCommentIsNull.

@Test
public void shouldConsiderFieldToBeEmptyWhenRevisionOrUsernameOrCommentIsNull() throws Exception {
    ScmMaterial material = material();
    repo.saveOrUpdate(material.createMaterialInstance());
    MaterialRevision userIsNullRevision = saveOneScmModification("40c95a3c41f54b5fb3107982cf2acd08783f102a", material, null, "meet_you_in_hell.txt", "bring it on!");
    MaterialRevision commentIsNullRevision = saveOneScmModification("c30c471137f31a4bf735f653f888e799f6deec04", material, "turn_her", "lets_party_in_hell.txt", null);
    List<MatchedRevision> revisions = repo.findRevisionsMatching(material.config(), "bring");
    assertThat(revisions.size(), is(1));
    assertMatchedRevision(revisions.get(0), userIsNullRevision.getLatestShortRevision(), userIsNullRevision.getLatestRevisionString(), null, userIsNullRevision.getDateOfLatestModification(), "bring it on!");
    revisions = repo.findRevisionsMatching(material.config(), "c04 turn");
    assertThat(revisions.size(), is(1));
    assertMatchedRevision(revisions.get(0), commentIsNullRevision.getLatestShortRevision(), commentIsNullRevision.getLatestRevisionString(), "turn_her", commentIsNullRevision.getDateOfLatestModification(), null);
    revisions = repo.findRevisionsMatching(material.config(), "null");
    assertThat(revisions.size(), is(0));
}
Also used : ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Test(org.junit.Test)

Example 9 with ScmMaterial

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

the class MaterialRepositoryIntegrationTest method shouldGetPaginatedModificationsForMaterialCorrectly.

@Test
public void shouldGetPaginatedModificationsForMaterialCorrectly() throws Exception {
    ScmMaterial material = material();
    MaterialInstance materialInstance = material.createMaterialInstance();
    repo.saveOrUpdate(materialInstance);
    MaterialRevision first = saveOneScmModification("1", material, "user1", "1.txt", "comment1");
    MaterialRevision second = saveOneScmModification("2", material, "user2", "2.txt", "comment2");
    MaterialRevision third = saveOneScmModification("3", material, "user3", "3.txt", "comment3");
    MaterialRevision fourth = saveOneScmModification("4", material, "user4", "4.txt", "comment4");
    MaterialRevision fifth = saveOneScmModification("5", material, "user5", "5.txt", "comment5");
    Modifications modifications = repo.getModificationsFor(materialInstance, Pagination.pageStartingAt(0, 5, 3));
    assertThat(modifications.size(), is(3));
    assertThat(modifications.get(0).getRevision(), is(fifth.getLatestRevisionString()));
    assertThat(modifications.get(1).getRevision(), is(fourth.getLatestRevisionString()));
    assertThat(modifications.get(2).getRevision(), is(third.getLatestRevisionString()));
    modifications = repo.getModificationsFor(materialInstance, Pagination.pageStartingAt(3, 5, 3));
    assertThat(modifications.size(), is(2));
    assertThat(modifications.get(0).getRevision(), is(second.getLatestRevisionString()));
    assertThat(modifications.get(1).getRevision(), is(first.getLatestRevisionString()));
}
Also used : ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) PackageMaterialInstance(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance) PluggableSCMMaterialInstance(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance) SvnMaterialInstance(com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance) Test(org.junit.Test)

Example 10 with ScmMaterial

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

the class MaterialChecker method findRevisionsSince.

public MaterialRevisions findRevisionsSince(MaterialRevisions peggedRevisions, Materials newMaterials, MaterialRevisions previous, MaterialRevisions latestRevisions) {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    for (Material material : newMaterials) {
        MaterialRevision previousRevision = previous.findRevisionFor(material);
        if (previousRevision == null) {
            materialRevisions.addRevision(latestRevisions.findRevisionFor(material));
        } else {
            Material previousMaterial = previousRevision.getMaterial();
            if (ensureHasRevisionForMaterial(peggedRevisions, materialRevisions, previousMaterial)) {
                continue;
            }
            previousMaterial = previousMaterial instanceof ScmMaterial ? newMaterials.byFolder(previousMaterial.getFolder()) : previousMaterial;
            List<Modification> newModifications = materialRepository.findModificationsSince(previousMaterial, previousRevision);
            MaterialRevision newMaterialRevision = previousRevision.latestChanges(material, previousRevision.getModifications(), newModifications);
            materialRevisions.addRevision(newMaterialRevision);
        }
    }
    return materialRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

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