Search in sources :

Example 1 with TransactionTemplate

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

the class PipelineTimelineTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    now = new DateTime();
    pipelineRepository = mock(PipelineRepository.class);
    materials = Arrays.asList("first", "second", "third", "fourth");
    first = PipelineMaterialModificationMother.modification(1, materials, Arrays.asList(now, now.plusMinutes(1), now.plusMinutes(2), now.plusMinutes(3)), 1, "111", "pipeline");
    second = PipelineMaterialModificationMother.modification(2, materials, Arrays.asList(now, now.plusMinutes(2), now.plusMinutes(1), now.plusMinutes(2)), 2, "222", "pipeline");
    third = PipelineMaterialModificationMother.modification(3, materials, Arrays.asList(now, now.plusMinutes(2), now.plusMinutes(1), now.plusMinutes(3)), 3, "333", "pipeline");
    fourth = PipelineMaterialModificationMother.modification(4, materials, Arrays.asList(now, now.plusMinutes(2), now.plusMinutes(3), now.plusMinutes(2)), 4, "444", "pipeline");
    pipelineName = "pipeline";
    transactionTemplate = mock(TransactionTemplate.class);
    transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
}
Also used : TransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TransactionSynchronizationManager) PipelineRepository(com.thoughtworks.go.server.persistence.PipelineRepository) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) DateTime(org.joda.time.DateTime) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with TransactionTemplate

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

the class PipelineSqlMapDaoCachingTest method setup.

@BeforeEach
void setup() throws Exception {
    transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    goCache.clear();
    mockTemplate = mock(SqlMapClientTemplate.class);
    repository = mock(MaterialRepository.class);
    environmentVariableDao = mock(EnvironmentVariableDao.class);
    SessionFactory mockSessionFactory = mock(SessionFactory.class);
    repository = mock(MaterialRepository.class);
    transactionTemplate = mock(TransactionTemplate.class);
    GoConfigDao configFileDao = mock(GoConfigDao.class);
    timeProvider = mock(TimeProvider.class);
    pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null, transactionSynchronizationManager, null, configFileDao, mock(Database.class), timeProvider);
    pipelineDao.setSqlMapClientTemplate(mockTemplate);
    Session session = mock(Session.class);
    when(mockSessionFactory.getCurrentSession()).thenReturn(session);
    when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
Also used : SessionFactory(org.hibernate.SessionFactory) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) TransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TransactionSynchronizationManager) TimeProvider(com.thoughtworks.go.util.TimeProvider) StubGoCache(com.thoughtworks.go.server.service.StubGoCache) SqlMapClientTemplate(com.thoughtworks.go.server.transaction.SqlMapClientTemplate) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) Session(org.hibernate.classic.Session) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with TransactionTemplate

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

the class PipelineStateDaoCachingTest method setup.

@BeforeEach
public void setup() throws Exception {
    transactionSynchronizationManager = mock(TransactionSynchronizationManager.class);
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    goCache.clear();
    mockTemplate = mock(SqlMapClientTemplate.class);
    mockSessionFactory = mock(SessionFactory.class);
    transactionTemplate = mock(TransactionTemplate.class);
    configFileDao = mock(GoConfigDao.class);
    pipelineStateDao = new PipelineStateDao(goCache, transactionTemplate, null, transactionSynchronizationManager, null, mock(Database.class), mockSessionFactory);
    pipelineStateDao.setSqlMapClientTemplate(mockTemplate);
    session = mock(Session.class);
    when(mockSessionFactory.getCurrentSession()).thenReturn(session);
    when(configFileDao.load()).thenReturn(GoConfigMother.defaultCruiseConfig());
}
Also used : SessionFactory(org.hibernate.SessionFactory) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) TransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TransactionSynchronizationManager) StubGoCache(com.thoughtworks.go.server.service.StubGoCache) SqlMapClientTemplate(com.thoughtworks.go.server.transaction.SqlMapClientTemplate) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) Session(org.hibernate.classic.Session) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with TransactionTemplate

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

the class PipelineServiceTriangleDependencyTest 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);
    notifier.disableUpdates();
}
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) MaterialRepository(com.thoughtworks.go.server.persistence.MaterialRepository) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with TransactionTemplate

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

the class PipelineStateDaoTest method setup.

@BeforeEach
void setup() {
    goCache = new StubGoCache(new TestTransactionSynchronizationManager());
    goCache.clear();
    mockSessionFactory = mock(SessionFactory.class);
    transactionTemplate = mock(TransactionTemplate.class);
    pipelineStateDao = new PipelineStateDao(goCache, transactionTemplate, null, null, null, mock(Database.class), mockSessionFactory);
    session = mock(Session.class);
    when(mockSessionFactory.getCurrentSession()).thenReturn(session);
}
Also used : SessionFactory(org.hibernate.SessionFactory) StubGoCache(com.thoughtworks.go.server.service.StubGoCache) TransactionTemplate(com.thoughtworks.go.server.transaction.TransactionTemplate) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) Session(org.hibernate.classic.Session) 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