Search in sources :

Example 41 with GitMaterialConfig

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));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) Test(org.junit.jupiter.api.Test)

Example 42 with GitMaterialConfig

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"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 43 with GitMaterialConfig

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()));
}
Also used : PipelineRunIdInfo(com.thoughtworks.go.domain.PipelineRunIdInfo) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 44 with GitMaterialConfig

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));
}
Also used : GitMaterialInstance(com.thoughtworks.go.domain.materials.git.GitMaterialInstance) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 45 with GitMaterialConfig

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));
}
Also used : GitMaterialInstance(com.thoughtworks.go.domain.materials.git.GitMaterialInstance) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) FeedModifier(com.thoughtworks.go.server.dao.FeedModifier) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7