use of com.thoughtworks.go.server.domain.JobStatusListener in project gocd by gocd.
the class JobInstanceServiceTest method shouldIgnoreErrorsWhenNotifyingListenersDuringSave.
@Test
public void shouldIgnoreErrorsWhenNotifyingListenersDuringSave() throws Exception {
final JobStatusListener failingListener = Mockito.mock(JobStatusListener.class, "listener1");
final JobStatusListener passingListener = Mockito.mock(JobStatusListener.class, "listener2");
doThrow(new RuntimeException("Should not be rethrown by save")).when(failingListener).jobStatusChanged(job);
final Pipeline pipeline = new NullPipeline();
final Stage stage = new Stage();
stage.setId(1);
final JobInstanceService jobService = new JobInstanceService(jobInstanceDao, null, null, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, failingListener, passingListener);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
public void doInTransactionWithoutResult(TransactionStatus status) {
jobService.save(new StageIdentifier(pipeline.getName(), null, pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter())), stage.getId(), job);
}
});
verify(jobInstanceDao).save(1l, job);
verify(passingListener).jobStatusChanged(job);
}
use of com.thoughtworks.go.server.domain.JobStatusListener in project gocd by gocd.
the class JobInstanceServiceTest method shouldRegisterANewListener.
@Test
public void shouldRegisterANewListener() throws SQLException {
JobInstanceService jobService = new JobInstanceService(jobInstanceDao, null, null, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService);
JobStatusListener listener = mock(JobStatusListener.class);
jobService.registerJobStateChangeListener(listener);
jobService.updateStateAndResult(job);
verify(jobInstanceDao).updateStateAndResult(job);
verify(listener).jobStatusChanged(job);
}
use of com.thoughtworks.go.server.domain.JobStatusListener in project gocd by gocd.
the class JobInstanceServiceTest method shouldNotifyAllListenersWhenSaveJob.
@Test
public void shouldNotifyAllListenersWhenSaveJob() throws Exception {
final JobStatusListener listener1 = Mockito.mock(JobStatusListener.class, "listener1");
final JobStatusListener listener2 = Mockito.mock(JobStatusListener.class, "listener2");
final Pipeline pipeline = new NullPipeline();
final Stage stage = new Stage();
stage.setId(1);
final JobInstanceService jobService = new JobInstanceService(jobInstanceDao, null, null, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, listener1, listener2);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
public void doInTransactionWithoutResult(TransactionStatus status) {
jobService.save(new StageIdentifier(pipeline.getName(), null, pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter())), stage.getId(), job);
}
});
verify(jobInstanceDao).save(1l, job);
verify(listener1).jobStatusChanged(job);
verify(listener2).jobStatusChanged(job);
}
use of com.thoughtworks.go.server.domain.JobStatusListener in project gocd by gocd.
the class JobInstanceServiceTest method shouldNotifyAllListenersWhenUpdateJobStatus.
@Test
public void shouldNotifyAllListenersWhenUpdateJobStatus() throws Exception {
final JobStatusListener listener1 = Mockito.mock(JobStatusListener.class, "listener1");
final JobStatusListener listener2 = Mockito.mock(JobStatusListener.class, "listener2");
JobInstanceService jobService = new JobInstanceService(jobInstanceDao, null, null, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, listener1, listener2);
jobService.updateStateAndResult(job);
verify(jobInstanceDao).updateStateAndResult(job);
verify(listener1).jobStatusChanged(job);
verify(listener2).jobStatusChanged(job);
}
use of com.thoughtworks.go.server.domain.JobStatusListener in project gocd by gocd.
the class PipelineServiceTest method shouldNotNotifyStatusListenersWhenTransactionRollsback.
@Test
public void shouldNotNotifyStatusListenersWhenTransactionRollsback() throws Exception {
StageStatusListener stageStatusListener = mock(StageStatusListener.class);
JobStatusListener jobStatusListener = mock(JobStatusListener.class);
Pipeline pipeline = stubPipelineSaveForStatusListener(stageStatusListener, jobStatusListener);
Mockito.doThrow(new RuntimeException()).when(pipelineTimeline).update();
try {
service.save(pipeline);
} catch (RuntimeException e) {
// ignore
}
verify(stageStatusListener, never()).stageStatusChanged(any(Stage.class));
verify(jobStatusListener, never()).jobStatusChanged(any(JobInstance.class));
}
Aggregations