use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoConfigWatchListTest method shouldReturnConfigRepoForMaterial.
@Test
public void shouldReturnConfigRepoForMaterial() {
GitMaterialConfig gitrepo = git("http://configrepo.git");
ConfigRepoConfig repoConfig = ConfigRepoConfig.createConfigRepoConfig(gitrepo, "myplugin", "id");
when(cruiseConfig.getConfigRepos()).thenReturn(new ConfigReposConfig(repoConfig));
watchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
assertThat(watchList.getConfigRepoForMaterial(gitrepo), is(repoConfig));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class CreateConfigRepoCommandTest method isValid_shouldValidateConfigRepo.
@Test
public void isValid_shouldValidateConfigRepo() {
GitMaterialConfig material = git("", "master");
configRepo.setRepo(material);
when(configRepoExtension.canHandlePlugin(configRepo.getPluginId())).thenReturn(true);
CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, currentUser, result, configRepoExtension);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertEquals("URL cannot be blank", configRepo.getRepo().errors().on("url"));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class MaterialServiceTest method shouldReturnNullIfNoInstanceIsPresent.
@Test
public void shouldReturnNullIfNoInstanceIsPresent() {
GitMaterialConfig materialConfig = git("http://test.com");
when(materialRepository.findMaterialInstance(materialConfig)).thenReturn(null);
PipelineRunIdInfo info = materialService.getLatestAndOldestModification(materialConfig, "");
verify(materialRepository, never()).getOldestAndLatestModificationId(anyLong(), anyString());
assertThat(info, is(nullValue()));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class MaterialServiceTest method history_shouldCallDaoToFetchModificationDataBeforeTheGivenCursor.
@Test
public void history_shouldCallDaoToFetchModificationDataBeforeTheGivenCursor() {
GitMaterialConfig materialConfig = git("http://test.com");
GitMaterialInstance gitMaterialInstance = new GitMaterialInstance("http://test.com", null, null, null, "flyweight");
Modifications modifications = new Modifications();
modifications.add(new Modification("user", "comment 1", "email", new DateTime().minusHours(1).toDate(), "revision"));
when(materialRepository.findMaterialInstance(materialConfig)).thenReturn(gitMaterialInstance);
when(materialRepository.loadHistory(anyLong(), any(), anyLong(), anyInt())).thenReturn(modifications);
List<Modification> gotModifications = materialService.getModificationsFor(materialConfig, "", 0, 2, 3);
verify(materialRepository).loadHistory(anyLong(), eq(FeedModifier.Before), eq(2L), eq(3));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class MaterialServiceTest method findMatchingMods_shouldCallDaoToFetchMatchingModsAfterCursor.
@Test
public void findMatchingMods_shouldCallDaoToFetchMatchingModsAfterCursor() {
GitMaterialConfig config = git("http://test.com");
GitMaterialInstance instance = new GitMaterialInstance("http://test.com", null, null, null, "flyweight");
Modifications modifications = new Modifications();
modifications.add(new Modification("user", "comment 1", "email", new DateTime().minusHours(1).toDate(), "revision"));
modifications.add(new Modification("user", "comment 2", "email", new DateTime().minusHours(2).toDate(), "revision"));
modifications.add(new Modification("user", "comment 3", "email", new DateTime().minusHours(3).toDate(), "revision"));
when(materialRepository.findMaterialInstance(config)).thenReturn(instance);
when(materialRepository.findMatchingModifications(anyLong(), anyString(), any(FeedModifier.class), anyLong(), anyInt())).thenReturn(modifications);
List<Modification> result = materialService.getModificationsFor(config, "comment", 3, 0, 10);
verify(materialRepository).findMatchingModifications(eq(instance.getId()), eq("comment"), eq(FeedModifier.After), eq(3L), eq(10));
assertThat(result, is(modifications));
}
Aggregations