Search in sources :

Example 6 with MaterialConfigConverter

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]);
        }
    });
}
Also used : SessionFactory(org.hibernate.SessionFactory) TransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TransactionSynchronizationManager) HibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) Answer(org.mockito.stubbing.Answer) MaterialExpansionService(com.thoughtworks.go.server.service.MaterialExpansionService) InvocationOnMock(org.mockito.invocation.InvocationOnMock) GoCache(com.thoughtworks.go.server.cache.GoCache) DatabaseStrategy(com.thoughtworks.go.server.database.DatabaseStrategy) Before(org.junit.Before)

Example 7 with MaterialConfigConverter

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;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter)

Example 8 with MaterialConfigConverter

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);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 9 with MaterialConfigConverter

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);
}
Also used : MDUPerformanceLogger(com.thoughtworks.go.server.perf.MDUPerformanceLogger) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PostCommitHookMaterialTypeResolver(com.thoughtworks.go.server.materials.postcommit.PostCommitHookMaterialTypeResolver) PostCommitHookMaterialType(com.thoughtworks.go.server.materials.postcommit.PostCommitHookMaterialType) Before(org.junit.Before)

Aggregations

MaterialConfigConverter (com.thoughtworks.go.server.service.MaterialConfigConverter)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 Material (com.thoughtworks.go.domain.materials.Material)3 Before (org.junit.Before)3 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)2 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)1 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 DatabaseStrategy (com.thoughtworks.go.server.database.DatabaseStrategy)1