use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.
the class MaterialRepositoryTest method setUp.
@Before
public void setUp() {
databaseStrategy = mock(DatabaseStrategy.class);
sessionFactory = mock(SessionFactory.class);
goCache = mock(GoCache.class);
ourCustomCache = new HashMap<>();
transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
mockHibernateTemplate = mock(HibernateTemplate.class);
materialConfigConverter = mock(MaterialConfigConverter.class);
materialExpansionService = mock(MaterialExpansionService.class);
materialRepository = new MaterialRepository(sessionFactory, goCache, 4242, transactionSynchronizationManager, materialConfigConverter, materialExpansionService, databaseStrategy);
materialRepository.setHibernateTemplate(mockHibernateTemplate);
when(goCache.get(anyString())).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
return ourCustomCache.get(arguments[0]);
}
});
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
return ourCustomCache.put((String) arguments[0], arguments[1]);
}
}).when(goCache).put(anyString(), anyObject());
when(goCache.remove(anyString())).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
return ourCustomCache.remove(arguments[0]);
}
});
}
use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.
the class DatabaseAccessHelper method newPipelineWithFirstStageFailed.
public Pipeline newPipelineWithFirstStageFailed(PipelineConfig config) throws SQLException {
Pipeline pipeline = instanceFactory.createPipelineInstance(config, BuildCause.createManualForced(modifyOneFile(new MaterialConfigConverter().toMaterials(config.materialConfigs()), ModificationsMother.currentRevision()), Username.ANONYMOUS), new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
savePipelineWithStagesAndMaterials(pipeline);
failStage(pipeline.getFirstStage());
return pipeline;
}
use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.
the class DatabaseAccessHelper method rescheduleTestPipeline.
public Pipeline rescheduleTestPipeline(String pipelineName, String stageName, String userName) throws SQLException {
String[] jobConfigNames = new String[] {};
PipelineConfig pipelineConfig = configurePipeline(pipelineName, stageName, jobConfigNames);
BuildCause buildCause = BuildCause.createManualForced(modifyOneFile(new MaterialConfigConverter().toMaterials(pipelineConfig.materialConfigs()), ModificationsMother.currentRevision()), Username.ANONYMOUS);
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, buildCause, new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY), md5, new TimeProvider());
return savePipelineWithStagesAndMaterials(pipeline);
}
use of com.thoughtworks.go.server.service.MaterialConfigConverter in project gocd by gocd.
the class MaterialUpdateServiceTest method setUp.
@Before
public void setUp() throws Exception {
queue = mock(MaterialUpdateQueue.class);
configQueue = mock(ConfigMaterialUpdateQueue.class);
watchList = mock(GoConfigWatchList.class);
completed = mock(MaterialUpdateCompletedTopic.class);
goConfigService = mock(GoConfigService.class);
postCommitHookMaterialType = mock(PostCommitHookMaterialTypeResolver.class);
serverHealthService = mock(ServerHealthService.class);
systemEnvironment = new SystemEnvironment();
scmMaterialSource = mock(SCMMaterialSource.class);
dependencyMaterialUpdateNotifier = mock(DependencyMaterialUpdateNotifier.class);
materialConfigConverter = mock(MaterialConfigConverter.class);
MDUPerformanceLogger mduPerformanceLogger = mock(MDUPerformanceLogger.class);
dependencyMaterialUpdateQueue = mock(DependencyMaterialUpdateQueue.class);
service = new MaterialUpdateService(queue, configQueue, completed, watchList, goConfigService, systemEnvironment, serverHealthService, postCommitHookMaterialType, mduPerformanceLogger, materialConfigConverter, dependencyMaterialUpdateQueue);
service.registerMaterialSources(scmMaterialSource);
service.registerMaterialUpdateCompleteListener(scmMaterialSource);
service.registerMaterialUpdateCompleteListener(dependencyMaterialUpdateNotifier);
HashSet<MaterialConfig> materialConfigs = new HashSet(Collections.singleton(MATERIAL_CONFIG));
HashSet<Material> materials = new HashSet(Collections.singleton(svnMaterial));
when(goConfigService.getSchedulableMaterials()).thenReturn(materialConfigs);
when(materialConfigConverter.toMaterials(materialConfigs)).thenReturn(materials);
username = new Username(new CaseInsensitiveString("loser"));
result = new HttpLocalizedOperationResult();
validMaterialType = mock(PostCommitHookMaterialType.class);
when(validMaterialType.isKnown()).thenReturn(true);
when(validMaterialType.isValid(anyString())).thenReturn(true);
invalidMaterialType = mock(PostCommitHookMaterialType.class);
when(invalidMaterialType.isKnown()).thenReturn(false);
when(invalidMaterialType.isValid(anyString())).thenReturn(false);
}
Aggregations