Search in sources :

Example 71 with SvnMaterial

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

the class MaterialCheckerTest method shouldSkipFindingRevisionsSinceForMaterialsThatWereAlreadyChecked.

@Test
public void shouldSkipFindingRevisionsSinceForMaterialsThatWereAlreadyChecked() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    SvnMaterial svnMaterial = new SvnMaterial("svnUrl", null, null, false);
    Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
    MaterialRevision previousDependantRevision = new MaterialRevision(dependencyMaterial, new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1[LABEL-1]/stage-name/0"));
    Modification dependencyModification = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/2[LABEL-2]/stage-name/0");
    MaterialRevision previousSvnRevision = new MaterialRevision(svnMaterial, mod(1L));
    Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "2");
    Mockito.when(materialRepository.findModificationsSince(svnMaterial, previousSvnRevision)).thenReturn(modifications(svnModification));
    MaterialRevisions alreadyFoundRevisions = new MaterialRevisions(new MaterialRevision(dependencyMaterial, dependencyModification));
    // will not be used, as no new materials have appeared
    MaterialRevisions latestRevisions = new MaterialRevisions();
    MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(alreadyFoundRevisions, new Materials(dependencyMaterial, svnMaterial), new MaterialRevisions(previousDependantRevision, previousSvnRevision), latestRevisions);
    assertThat(revisionsSince, is(new MaterialRevisions(new MaterialRevision(dependencyMaterial, dependencyModification), new MaterialRevision(svnMaterial, svnModification))));
    Mockito.verify(materialRepository, never()).findLatestModification(dependencyMaterial);
    Mockito.verify(materialRepository).findModificationsSince(svnMaterial, previousSvnRevision);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 72 with SvnMaterial

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

the class MaterialUpdateServiceTest method setUp.

@Before
public void setUp() throws Exception {
    queue = mock(MaterialUpdateQueue.class);
    configQueue = mock(ConfigMaterialUpdateQueue.class);
    watchList = mock(GoConfigWatchList.class);
    completed = mock(MaterialUpdateCompletedTopic.class);
    goConfigService = mock(GoConfigService.class);
    postCommitHookMaterialType = mock(PostCommitHookMaterialTypeResolver.class);
    serverHealthService = mock(ServerHealthService.class);
    systemEnvironment = new SystemEnvironment();
    scmMaterialSource = mock(SCMMaterialSource.class);
    dependencyMaterialUpdateNotifier = mock(DependencyMaterialUpdateNotifier.class);
    materialConfigConverter = mock(MaterialConfigConverter.class);
    MDUPerformanceLogger mduPerformanceLogger = mock(MDUPerformanceLogger.class);
    dependencyMaterialUpdateQueue = mock(DependencyMaterialUpdateQueue.class);
    service = new MaterialUpdateService(queue, configQueue, completed, watchList, goConfigService, systemEnvironment, serverHealthService, postCommitHookMaterialType, mduPerformanceLogger, materialConfigConverter, dependencyMaterialUpdateQueue);
    service.registerMaterialSources(scmMaterialSource);
    service.registerMaterialUpdateCompleteListener(scmMaterialSource);
    service.registerMaterialUpdateCompleteListener(dependencyMaterialUpdateNotifier);
    HashSet<MaterialConfig> materialConfigs = new HashSet(Collections.singleton(MATERIAL_CONFIG));
    HashSet<Material> materials = new HashSet(Collections.singleton(svnMaterial));
    when(goConfigService.getSchedulableMaterials()).thenReturn(materialConfigs);
    when(materialConfigConverter.toMaterials(materialConfigs)).thenReturn(materials);
    username = new Username(new CaseInsensitiveString("loser"));
    result = new HttpLocalizedOperationResult();
    validMaterialType = mock(PostCommitHookMaterialType.class);
    when(validMaterialType.isKnown()).thenReturn(true);
    when(validMaterialType.isValid(anyString())).thenReturn(true);
    invalidMaterialType = mock(PostCommitHookMaterialType.class);
    when(invalidMaterialType.isKnown()).thenReturn(false);
    when(invalidMaterialType.isValid(anyString())).thenReturn(false);
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PostCommitHookMaterialTypeResolver(com.thoughtworks.go.server.materials.postcommit.PostCommitHookMaterialTypeResolver) PostCommitHookMaterialType(com.thoughtworks.go.server.materials.postcommit.PostCommitHookMaterialType) Before(org.junit.Before)

Example 73 with SvnMaterial

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

the class GitPostCommitHookImplementerTest method shouldQueryOnlyGitMaterialsWhilePruning.

@Test
public void shouldQueryOnlyGitMaterialsWhilePruning() throws Exception {
    SvnMaterial material1 = mock(SvnMaterial.class);
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    HashMap params = new HashMap();
    params.put(GitPostCommitHookImplementer.REPO_URL_PARAM_KEY, "https://machine.local.git");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.Test)

Example 74 with SvnMaterial

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

the class PluggableSCMPostCommitHookImplementerTest method shouldQueryOnlyPluggableSCMMaterialsWhilePruning.

@Test
public void shouldQueryOnlyPluggableSCMMaterialsWhilePruning() throws Exception {
    SvnMaterial material1 = mock(SvnMaterial.class);
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    Map params = new HashMap();
    params.put(PluggableSCMPostCommitHookImplementer.SCM_NAME, "scm-material-1");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.Test)

Example 75 with SvnMaterial

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

the class MaterialExpansionServiceTest method shouldExpandSvnMaterialWithExternalsIntoMultipleSvnMaterialsWhenExpandingForHistory.

@Test
public void shouldExpandSvnMaterialWithExternalsIntoMultipleSvnMaterialsWhenExpandingForHistory() {
    SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), "mainRepo", "user1", "pass1", true, "*.doc");
    SvnMaterial expectedExternalSvnMaterial = new SvnMaterial(svnRepo.externalRepositoryUrl(), "user1", "pass1", true, "mainRepo/" + svnRepo.externalMaterial().getFolder());
    expectedExternalSvnMaterial.setFilter(FilterMother.filterFor("*.doc"));
    when(materialConfigConverter.toMaterials(new MaterialConfigs(svn.config(), expectedExternalSvnMaterial.config()))).thenReturn(new Materials(svn, expectedExternalSvnMaterial));
    Materials materials = new Materials();
    materialExpansionService.expandForScheduling(svn, materials);
    assertThat(materials.size(), is(2));
    assertThat(materials.get(0), is(svn));
    assertThat(((SvnMaterial) materials.get(1)).getUrl(), endsWith("end2end/"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials)

Aggregations

SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)140 Test (org.junit.Test)111 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)44 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)39 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)22 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)21 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)20 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)18 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)17 Material (com.thoughtworks.go.domain.materials.Material)16 Modification (com.thoughtworks.go.domain.materials.Modification)16 Materials (com.thoughtworks.go.config.materials.Materials)13 Date (java.util.Date)11 Username (com.thoughtworks.go.server.domain.Username)10 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)9 File (java.io.File)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7