Search in sources :

Example 6 with TransactionTemplate

use of com.thoughtworks.go.server.transaction.TransactionTemplate in project gocd by gocd.

the class PackageMaterialUpdaterTest method setup.

@BeforeEach
public void setup() {
    transactionTemplate = new TransactionTemplate(null) {

        @Override
        public Object execute(TransactionCallback action) {
            return action.doInTransaction(null);
        }

        @Override
        public Object executeWithExceptionHandling(com.thoughtworks.go.server.transaction.TransactionCallback action) throws Exception {
            // To change body of overridden methods use File | Settings | File Templates.
            return super.executeWithExceptionHandling(action);
        }

        @Override
        public <T extends Exception> Object transactionSurrounding(TransactionSurrounding<T> surrounding) throws T {
            // To change body of overridden methods use File | Settings | File Templates.
            return super.transactionSurrounding(surrounding);
        }
    };
    materialUpdater = new PackageMaterialUpdater(materialRepository, scmMaterialUpdater, transactionTemplate);
}
Also used : TransactionCallback(org.springframework.transaction.support.TransactionCallback) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with TransactionTemplate

use of com.thoughtworks.go.server.transaction.TransactionTemplate in project gocd by gocd.

the class PluggableSCMMaterialUpdaterTest method setup.

@BeforeEach
public void setup() {
    transactionTemplate = new TransactionTemplate(null) {

        @Override
        public Object execute(TransactionCallback action) {
            return action.doInTransaction(null);
        }

        @Override
        public Object executeWithExceptionHandling(com.thoughtworks.go.server.transaction.TransactionCallback action) throws Exception {
            // To change body of overridden methods use File | Settings | File Templates.
            return super.executeWithExceptionHandling(action);
        }

        @Override
        public <T extends Exception> Object transactionSurrounding(TransactionSurrounding<T> surrounding) throws T {
            // To change body of overridden methods use File | Settings | File Templates.
            return super.transactionSurrounding(surrounding);
        }
    };
    materialUpdater = new PluggableSCMMaterialUpdater(materialRepository, scmMaterialUpdater, transactionTemplate);
}
Also used : TransactionCallback(org.springframework.transaction.support.TransactionCallback) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with TransactionTemplate

use of com.thoughtworks.go.server.transaction.TransactionTemplate in project gocd by gocd.

the class PipelineServiceTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    pipelineTimeline = mock(PipelineTimeline.class);
    pipelineDao = mock(PipelineSqlMapDao.class);
    materialRepository = mock(MaterialRepository.class);
    TestTransactionSynchronizationManager mockTransactionSynchronizationManager = new TestTransactionSynchronizationManager();
    TransactionTemplate mockTransactionTemplate = new TestTransactionTemplate(mockTransactionSynchronizationManager);
    service = new PipelineService(pipelineDao, mock(StageService.class), mock(PipelineLockService.class), pipelineTimeline, materialRepository, mockTransactionTemplate, systemEnvironment, null, materialConfigConverter);
    first = oneModifiedFile("1");
    third = oneModifiedFile("3");
    second = oneModifiedFile("2");
    first.setId(1);
    third.setId(3);
    second.setId(2);
}
Also used : PipelineSqlMapDao(com.thoughtworks.go.server.dao.PipelineSqlMapDao) TestTransactionTemplate(com.thoughtworks.go.server.transaction.TestTransactionTemplate) TestTransactionTemplate(com.thoughtworks.go.server.transaction.TestTransactionTemplate) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

TransactionTemplate (com.thoughtworks.go.server.transaction.TransactionTemplate)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)5 MaterialRepository (com.thoughtworks.go.server.persistence.MaterialRepository)3 StubGoCache (com.thoughtworks.go.server.service.StubGoCache)3 TransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TransactionSynchronizationManager)3 SessionFactory (org.hibernate.SessionFactory)3 Session (org.hibernate.classic.Session)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2 PipelineSqlMapDao (com.thoughtworks.go.server.dao.PipelineSqlMapDao)2 SqlMapClientTemplate (com.thoughtworks.go.server.transaction.SqlMapClientTemplate)2 TestTransactionTemplate (com.thoughtworks.go.server.transaction.TestTransactionTemplate)2 TransactionCallback (org.springframework.transaction.support.TransactionCallback)2 PipelineTimeline (com.thoughtworks.go.server.domain.PipelineTimeline)1 PipelineRepository (com.thoughtworks.go.server.persistence.PipelineRepository)1 TimeProvider (com.thoughtworks.go.util.TimeProvider)1 DateTime (org.joda.time.DateTime)1