use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnPostCommitHookImplementerTest method shouldReturnEmptyListWhenUUIDIsNotPresent.
@Test
public void shouldReturnEmptyListWhenUUIDIsNotPresent() {
final SvnMaterial svnMaterial1 = mock(SvnMaterial.class);
final HashSet<Material> allMaterials = new HashSet<>();
allMaterials.add(svnMaterial1);
final SvnPostCommitHookImplementer spy = spy(implementer);
final Set<Material> prunedList = spy.prune(allMaterials, new HashMap());
assertThat(prunedList.size(), is(0));
verify(spy, never()).isQualified(anyString(), any(SvnMaterial.class), any(HashMap.class));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnPostCommitHookImplementerTest method shouldCreateRemoteUrlToRemoteUUIDMap.
@Test
public void shouldCreateRemoteUrlToRemoteUUIDMap() {
final SvnPostCommitHookImplementer spy = spy(implementer);
final SvnCommand svnCommand = mock(SvnCommand.class);
final Material svnMaterial1 = mock(SvnMaterial.class);
final Material hgMaterial1 = mock(HgMaterial.class);
final HashSet<Material> allMaterials = new HashSet<>(Arrays.asList(svnMaterial1, hgMaterial1));
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return svnCommand;
}
}).when(spy).getEmptySvnCommand();
spy.createUrlToRemoteUUIDMap(allMaterials);
verify(svnCommand).createUrlToRemoteUUIDMap(new HashSet<>(Arrays.asList((SvnMaterial) svnMaterial1)));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnPostCommitHookImplementerTest method shouldPruneListToGiveOutOnlySvnMaterialsWhichMatchTheRepositoryUUID.
@Test
public void shouldPruneListToGiveOutOnlySvnMaterialsWhichMatchTheRepositoryUUID() {
final SvnMaterial svnMaterial1 = mock(SvnMaterial.class);
final SvnMaterial svnMaterial2 = mock(SvnMaterial.class);
final SvnMaterial svnMaterial3 = mock(SvnMaterial.class);
final HashSet<Material> allMaterials = new HashSet<>(Arrays.asList(svnMaterial1, svnMaterial2, svnMaterial3));
final HashMap<Object, Object> params = new HashMap<>();
final String uuid = "12345";
params.put(SvnPostCommitHookImplementer.UUID, uuid);
final SvnPostCommitHookImplementer spy = spy(implementer);
final HashMap<String, String> map = new HashMap<>();
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
map.put("url1", "12345");
map.put("url2", "54321");
return map;
}
}).when(spy).createUrlToRemoteUUIDMap(allMaterials);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return Boolean.FALSE;
}
}).when(spy).isQualified(uuid, svnMaterial1, map);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return Boolean.TRUE;
}
}).when(spy).isQualified(uuid, svnMaterial2, map);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return Boolean.FALSE;
}
}).when(spy).isQualified(uuid, svnMaterial3, map);
final Set<Material> prunedList = spy.prune(allMaterials, params);
assertThat(prunedList.size(), is(1));
verify(spy, times(1)).createUrlToRemoteUUIDMap(allMaterials);
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldCheckForModificationsWhenManuallyScheduling.
@Test
public void shouldCheckForModificationsWhenManuallyScheduling() throws Exception {
HgMaterialConfig hgMaterialConfig = new HgMaterialConfig("url", null);
HgMaterial hgMaterial = new HgMaterial("url", null);
SvnMaterial svnMaterial = new SvnMaterial("url", null, null, false);
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig("url", null, null, false);
pipelineConfig.addMaterialConfig(hgMaterialConfig);
pipelineConfig.addMaterialConfig(svnMaterialConfig);
when(materialConfigConverter.toMaterial(hgMaterialConfig)).thenReturn(hgMaterial);
when(materialConfigConverter.toMaterial(svnMaterialConfig)).thenReturn(svnMaterial);
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(), result);
assertThat(result.getServerHealthState().isSuccess(), is(true));
verify(mockMaterialUpdateService, times(2)).updateMaterial(any(Material.class));
verify(mockMaterialUpdateStatusNotifier).registerListenerFor(eq(pipelineConfig), any(MaterialUpdateStatusListener.class));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldBeAbleToPassInSpecificRevisionForMaterialsAndScheduleABuild.
@Test
public void shouldBeAbleToPassInSpecificRevisionForMaterialsAndScheduleABuild() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("stage"));
SvnMaterial svnMaterial = new SvnMaterial("url", null, null, false);
pipelineConfig.addMaterialConfig(dependencyMaterial.config());
pipelineConfig.addMaterialConfig(svnMaterial.config());
List<Modification> svnModifications = ModificationsMother.multipleModificationList();
MaterialConfigs knownMaterialConfigs = new MaterialConfigs(pipelineConfig.materialConfigs());
MaterialRevision specificMaterialRevision = new MaterialRevision(dependencyMaterial, new Modification(new Date(), "upstream-pipeline/2/stage/1", "MOCK_LABEL-12", null));
when(specificMaterialRevisionFactory.create(eq("pipeline"), eq(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/2/stage/1")))).thenReturn(new MaterialRevisions(specificMaterialRevision));
when(pipelineScheduleQueue.mostRecentScheduled("pipeline")).thenReturn(BuildCause.createNeverRun());
when(materialRepository.findLatestModification(svnMaterial)).thenReturn(new MaterialRevisions(new MaterialRevision(svnMaterial, svnModifications)));
when(materialConfigConverter.toMaterials(pipelineConfig.materialConfigs())).thenReturn(new Materials(dependencyMaterial, svnMaterial));
when(materialExpansionService.expandMaterialConfigsForScheduling(pipelineConfig.materialConfigs())).thenReturn(knownMaterialConfigs);
when(materialConfigConverter.toMaterials(knownMaterialConfigs)).thenReturn(new Materials(dependencyMaterial, svnMaterial));
ManualBuild buildType = new ManualBuild(Username.ANONYMOUS);
final HashMap<String, String> stringStringHashMap = new HashMap<>();
buildCauseProducerService.newProduceBuildCause(pipelineConfig, buildType, new ScheduleOptions(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/2/stage/1"), stringStringHashMap, new HashMap<>()), new ServerHealthStateOperationResult(), 12345);
verify(pipelineScheduleQueue).schedule(eq("pipeline"), argThat(containsRevisions(new MaterialRevision(svnMaterial, svnModifications), specificMaterialRevision)));
}
Aggregations