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