use of com.thoughtworks.go.domain.materials.TestingMaterialInstance in project gocd by gocd.
the class ConfigRepositoryInitializerTest method shouldNotReInitializeConfigRepositoriesWhenCruiseConfigListenerIsInvokedAgain.
@Test
void shouldNotReInitializeConfigRepositoriesWhenCruiseConfigListenerIsInvokedAgain() {
GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) repoConfigs.get(0).getRepo();
Material gitMaterial = new Materials(new MaterialConfigs(gitMaterialConfig)).first();
TestingMaterialInstance gitMaterialInstance = new TestingMaterialInstance("git-repo", "flyweight");
File folder = new File("repo-folder");
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(gitMaterial, oneModifiedFile("revision1")));
Modification modification = materialRevisions.firstModifiedMaterialRevision().getLatestModification();
when(materialRepository.findMaterialInstance(gitMaterialConfig)).thenReturn(gitMaterialInstance);
when(materialRepository.folderFor(gitMaterial)).thenReturn(folder);
when(materialRepository.findLatestModification(gitMaterial)).thenReturn(materialRevisions);
configRepositoryInitializer.onConfigChange(new BasicCruiseConfig());
configRepositoryInitializer.pluginLoaded(yamlPluginDescriptor);
verify(goConfigRepoConfigDataSource, times(1)).onCheckoutComplete(gitMaterialConfig, folder, modification);
// config changes..
configRepositoryInitializer.onConfigChange(new BasicCruiseConfig());
verifyNoMoreInteractions(goConfigRepoConfigDataSource);
}
use of com.thoughtworks.go.domain.materials.TestingMaterialInstance in project gocd by gocd.
the class ConfigRepositoryInitializerTest method shouldInitializeConfigRepositoryAsAndWhenPluginsAreLoaded.
@Test
void shouldInitializeConfigRepositoryAsAndWhenPluginsAreLoaded() {
// add another config repo using another plugin id
ConfigRepoConfig repoConfig2 = new ConfigRepoConfig();
repoConfig2.setId("repo2");
repoConfig2.setPluginId(JSON_PLUGIN_ID);
repoConfig2.setRepo(MaterialConfigsMother.git("git-repo"));
repoConfigs.add(repoConfig2);
GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) repoConfigs.get(0).getRepo();
Material gitMaterial = new Materials(new MaterialConfigs(gitMaterialConfig)).first();
TestingMaterialInstance gitMaterialInstance = new TestingMaterialInstance("git-repo", "flyweight");
File folder = new File("repo-folder");
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(gitMaterial, oneModifiedFile("revision1")));
Modification modification = materialRevisions.firstModifiedMaterialRevision().getLatestModification();
when(materialRepository.findMaterialInstance(gitMaterialConfig)).thenReturn(gitMaterialInstance);
when(materialRepository.folderFor(gitMaterial)).thenReturn(folder);
when(materialRepository.findLatestModification(gitMaterial)).thenReturn(materialRevisions);
// initialize config
configRepositoryInitializer.onConfigChange(new BasicCruiseConfig());
// load yaml plugin
configRepositoryInitializer.pluginLoaded(yamlPluginDescriptor);
// verify the config repo is initialized once all the in use plugins are loaded
verify(goConfigRepoConfigDataSource, times(1)).onCheckoutComplete(gitMaterialConfig, folder, modification);
// load json plugin
configRepositoryInitializer.pluginLoaded(jsonPluginDescriptor);
// verify the config repo is initialized once all the in use plugins are loaded
verify(goConfigRepoConfigDataSource, times(2)).onCheckoutComplete(gitMaterialConfig, folder, modification);
// load groovy plugin
configRepositoryInitializer.pluginLoaded(groovyPluginDescriptor);
// verify nothing happens on more plugin load
verifyNoMoreInteractions(goConfigRepoConfigDataSource);
}
use of com.thoughtworks.go.domain.materials.TestingMaterialInstance in project gocd by gocd.
the class ConfigRepositoryInitializerTest method shouldInitializeConfigRepositoriesWhenCruiseConfigAndAllInUsePluginsAreLoaded.
@Test
void shouldInitializeConfigRepositoriesWhenCruiseConfigAndAllInUsePluginsAreLoaded() {
GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) repoConfigs.get(0).getRepo();
Material gitMaterial = new Materials(new MaterialConfigs(gitMaterialConfig)).first();
TestingMaterialInstance gitMaterialInstance = new TestingMaterialInstance("git-repo", "flyweight");
File folder = new File("repo-folder");
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(gitMaterial, oneModifiedFile("revision1")));
Modification modification = materialRevisions.firstModifiedMaterialRevision().getLatestModification();
when(materialRepository.findMaterialInstance(gitMaterialConfig)).thenReturn(gitMaterialInstance);
when(materialRepository.folderFor(gitMaterial)).thenReturn(folder);
when(materialRepository.findLatestModification(gitMaterial)).thenReturn(materialRevisions);
configRepositoryInitializer.onConfigChange(new BasicCruiseConfig());
configRepositoryInitializer.pluginLoaded(yamlPluginDescriptor);
verify(goConfigRepoConfigDataSource, times(1)).onCheckoutComplete(gitMaterialConfig, folder, modification);
}
Aggregations