Search in sources :

Example 31 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class MaterialUpdateServiceTest method shouldRemoveServerHealthMessageOnMaterialUpdateCompletion.

@Test
void shouldRemoveServerHealthMessageOnMaterialUpdateCompletion() {
    Material material = mock(Material.class);
    when(material.getFingerprint()).thenReturn("fingerprint");
    service.onMessage(new MaterialUpdateCompletedMessage(material, 0));
    verify(serverHealthService).removeByScope(HealthStateScope.forMaterialUpdate(material));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialsMother.gitMaterial(com.thoughtworks.go.helper.MaterialsMother.gitMaterial) Test(org.junit.jupiter.api.Test)

Example 32 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class MaterialUpdateServiceTest method shouldNotRemoveServerHealthMessageOnMaterialUpdateSkippedMessage.

@Test
void shouldNotRemoveServerHealthMessageOnMaterialUpdateSkippedMessage() {
    Material material = mock(Material.class);
    service.onMessage(new MaterialUpdateSkippedMessage(material, 0));
    verifyNoInteractions(serverHealthService);
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialsMother.gitMaterial(com.thoughtworks.go.helper.MaterialsMother.gitMaterial) Test(org.junit.jupiter.api.Test)

Example 33 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class SCMMaterialSourceTest method shouldRefreshMaterialCacheOnPackageRepositoryChange.

@Test
public void shouldRefreshMaterialCacheOnPackageRepositoryChange() {
    GitMaterialConfig gitMaterial = new GitMaterialConfig();
    gitMaterial.setUrl("http://github.com/gocd/gocd");
    ArgumentCaptor<EntityConfigChangedListener> captor = ArgumentCaptor.forClass(EntityConfigChangedListener.class);
    doNothing().when(goConfigService).register(captor.capture());
    when(goConfigService.getSchedulableSCMMaterials()).thenReturn(emptySet()).thenReturn(singleton(gitMaterial));
    source = new SCMMaterialSource(goConfigService, systemEnvironment, new MaterialConfigConverter(), materialUpdateService);
    source.initialize();
    EntityConfigChangedListener entityConfigChangedListener = captor.getAllValues().get(1);
    assertTrue(entityConfigChangedListener.shouldCareAbout(new PackageRepository()));
    assertThat(source.materialsForUpdate().size(), is(0));
    entityConfigChangedListener.onEntityConfigChange(new PackageRepository());
    Set<Material> materials = source.materialsForUpdate();
    assertThat(materials.size(), is(1));
    assertThat(materials.iterator().next().getFingerprint(), is(gitMaterial.getFingerprint()));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Material(com.thoughtworks.go.domain.materials.Material) EntityConfigChangedListener(com.thoughtworks.go.listener.EntityConfigChangedListener) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) Test(org.junit.jupiter.api.Test)

Example 34 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class ConfigRepositoryInitializer method initializeConfigRepository.

private void initializeConfigRepository(ConfigRepoConfig repo) {
    MaterialConfig materialConfig = repo.getRepo();
    Material material = new Materials(new MaterialConfigs(materialConfig)).first();
    MaterialInstance materialInstance = this.materialRepository.findMaterialInstance(materialConfig);
    if (materialInstance != null) {
        File folder = materialRepository.folderFor(material);
        MaterialRevisions latestModification = materialRepository.findLatestModification(material);
        Modification modification = latestModification.firstModifiedMaterialRevision().getLatestModification();
        try {
            LOGGER.debug("[Config Repository Initializer] Initializing config repository '{}'. Loading the GoCD configuration from last fetched modification '{}'.", repo.getId(), modification.getRevision());
            goConfigRepoConfigDataSource.onCheckoutComplete(materialConfig, folder, modification);
        } catch (Exception e) {
            LOGGER.error(String.format("[Config Repository Initializer] an error occurred while initializing '%s' config repository.", repo.getId()), e);
        // Do nothing when error occurs while initializing the config repository.
        // The config repo initialization may fail due to config repo errors (config errors, or rules violation errors)
        }
    } else {
        LOGGER.debug("[Config Repository Initializer] Skipped initializing config repository '{}'. Could not find material repository under flyweight folder.", repo.getId());
    }
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Material(com.thoughtworks.go.domain.materials.Material) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File)

Example 35 with Material

use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.

the class ChangesetService method toMaterialRevisionList.

private List<MaterialRevision> toMaterialRevisionList(Map<Material, Modifications> map) {
    List<MaterialRevision> materialRevisionsAcrossPipelines = new ArrayList<>();
    for (Map.Entry<Material, Modifications> materialToModifications : map.entrySet()) {
        Modifications modifications = new Modifications(new ArrayList<>(materialToModifications.getValue()));
        materialRevisionsAcrossPipelines.add(new MaterialRevision(materialToModifications.getKey(), modifications));
    }
    return materialRevisionsAcrossPipelines;
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

Material (com.thoughtworks.go.domain.materials.Material)122 Test (org.junit.jupiter.api.Test)72 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)47 Modification (com.thoughtworks.go.domain.materials.Modification)29 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)24 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)19 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)19 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)18 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)18 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)16 Materials (com.thoughtworks.go.config.materials.Materials)14 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)13 File (java.io.File)13 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)12 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)8