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