Search in sources :

Example 1 with AbstractTaskletStepBuilder

use of org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder in project hub-alert by blackducksoftware.

the class CommonConfigTest method testCreateStep.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testCreateStep() {
    final StepBuilderFactory stepBuilderFactory = Mockito.mock(StepBuilderFactory.class);
    final TaskExecutor taskExecutor = Mockito.mock(TaskExecutor.class);
    final PlatformTransactionManager transactionManager = Mockito.mock(PlatformTransactionManager.class);
    final C config = getConfigWithParams(stepBuilderFactory, taskExecutor, transactionManager);
    final R reader = getMockReader();
    final P processor = getMockProcessor();
    final W writer = getMockWriter();
    final StepBuilder stepBuilder = Mockito.mock(StepBuilder.class);
    final SimpleStepBuilder simpleStepBuilder = Mockito.mock(SimpleStepBuilder.class);
    final AbstractTaskletStepBuilder abstractTaskletStepBuilder = Mockito.mock(AbstractTaskletStepBuilder.class);
    Mockito.when(stepBuilderFactory.get(Mockito.anyString())).thenReturn(stepBuilder);
    Mockito.when(stepBuilder.chunk(Mockito.anyInt())).thenReturn(simpleStepBuilder);
    Mockito.when(simpleStepBuilder.reader(reader)).thenReturn(simpleStepBuilder);
    Mockito.when(simpleStepBuilder.processor(processor)).thenReturn(simpleStepBuilder);
    Mockito.when(simpleStepBuilder.writer(writer)).thenReturn(simpleStepBuilder);
    Mockito.when(simpleStepBuilder.taskExecutor(taskExecutor)).thenReturn(abstractTaskletStepBuilder);
    Mockito.when(abstractTaskletStepBuilder.transactionManager(transactionManager)).thenReturn(abstractTaskletStepBuilder);
    Mockito.when(abstractTaskletStepBuilder.build()).thenReturn(new TaskletStep());
    final Step step = config.createStep(reader, processor, writer);
    assertNotNull(step);
}
Also used : AbstractTaskletStepBuilder(org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder) TaskExecutor(org.springframework.core.task.TaskExecutor) AbstractTaskletStepBuilder(org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder) SimpleStepBuilder(org.springframework.batch.core.step.builder.SimpleStepBuilder) StepBuilder(org.springframework.batch.core.step.builder.StepBuilder) SimpleStepBuilder(org.springframework.batch.core.step.builder.SimpleStepBuilder) StepBuilderFactory(org.springframework.batch.core.configuration.annotation.StepBuilderFactory) TaskletStep(org.springframework.batch.core.step.tasklet.TaskletStep) Step(org.springframework.batch.core.Step) TaskletStep(org.springframework.batch.core.step.tasklet.TaskletStep) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Step (org.springframework.batch.core.Step)1 StepBuilderFactory (org.springframework.batch.core.configuration.annotation.StepBuilderFactory)1 AbstractTaskletStepBuilder (org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder)1 SimpleStepBuilder (org.springframework.batch.core.step.builder.SimpleStepBuilder)1 StepBuilder (org.springframework.batch.core.step.builder.StepBuilder)1 TaskletStep (org.springframework.batch.core.step.tasklet.TaskletStep)1 TaskExecutor (org.springframework.core.task.TaskExecutor)1 PlatformTransactionManager (org.springframework.transaction.PlatformTransactionManager)1