Package org.springframework.batch.core.job.flow

Examples of org.springframework.batch.core.job.flow.Flow


    }

    @Test
    public void testStart() throws FlowExecutionException {
        FlowExecutor flowExecutor = createFlowExecutor("testStartJob", "testStartStep");
        Flow flow = new Flow() {
            public String getName() {
                return "testStart";
            }

            public State getState(String stateName) {
                return null;
            }

            public FlowExecution start(FlowExecutor executor)
                    throws FlowExecutionException {
                return null;
            }

            public FlowExecution resume(String stateName, FlowExecutor executor)
                    throws FlowExecutionException {
                throw new FlowExecutionException("Unexpected resume call");
            }

            public Collection<State> getStates() {
                return Collections.emptyList();
            }
        };
        flow.start(flowExecutor);

        Operation op = assertOperationDetails(getLastEntered(), "start", flow.getName());
        assertOperationPath(op, flowExecutor);
    }
View Full Code Here


    }

    @Test
    public void testResume() throws FlowExecutionException {
        FlowExecutor flowExecutor = createFlowExecutor("testResumeJob", "testResumeStep");
        Flow flow = new Flow() {
            public String getName() {
                return "testResume";
            }

            public State getState(String stateName) {
                return null;
            }

            public FlowExecution start(FlowExecutor executor)
                    throws FlowExecutionException {
                throw new FlowExecutionException("Unexpected start call");
            }

            public FlowExecution resume(String stateName, FlowExecutor executor)
                    throws FlowExecutionException {
                return null;
            }

            public Collection<State> getStates() {
                return Collections.emptyList();
            }
        };
        flow.resume("test", flowExecutor);

        Operation op = assertOperationDetails(getLastEntered(), "resume", flow.getName());
        assertEquals("Mismatched state value", "test", op.get("flowState", String.class));
        assertOperationPath(op, flowExecutor);
    }
View Full Code Here

    public FlowBuilder<Q> add(Flow... flows) {
      Collection<Flow> list = new ArrayList<Flow>(Arrays.asList(flows));
      String name = "split" + (parent.splitCounter++);
      int counter = 0;
      State one = parent.currentState;
      Flow flow = null;
      if (!(one instanceof FlowState)) {
        FlowBuilder<Flow> stateBuilder = new FlowBuilder<Flow>(name + "_" + (counter++));
        stateBuilder.currentState = one;
        flow = stateBuilder.build();
      }
View Full Code Here

   *
   * @see org.springframework.batch.core.job.builder.FlowBuilder#build()
   */
  @Override
  public FlowJobBuilder build() {
    Flow flow = flow();

    if(flow instanceof InitializingBean) {
      try {
        ((InitializingBean) flow).afterPropertiesSet();
      }
View Full Code Here

    assertEquals(2, execution.getStepExecutions().size());
  }

  @Test
  public void testBuildSingleFlow() throws Exception {
    Flow flow = new FlowBuilder<Flow>("subflow").from(step1).next(step2).build();
    FlowJobBuilder builder = new JobBuilder("flow").repository(jobRepository).start(flow).end().preventRestart();
    builder.build().execute(execution);
    assertEquals(BatchStatus.COMPLETED, execution.getStatus());
    assertEquals(2, execution.getStepExecutions().size());
  }
View Full Code Here

    assertEquals(2, execution.getStepExecutions().size());
  }

  @Test
  public void testBuildSubflow() throws Exception {
    Flow flow = new FlowBuilder<Flow>("subflow").from(step1).end();
    JobFlowBuilder builder = new JobBuilder("flow").repository(jobRepository).start(flow);
    builder.on("COMPLETED").to(step2);
    builder.end().preventRestart().build().execute(execution);
    assertEquals(BatchStatus.COMPLETED, execution.getStatus());
    assertEquals(2, execution.getStepExecutions().size());
View Full Code Here

    assertEquals(2, execution.getStepExecutions().size());
  }

  @Test
  public void testBuildSplit() throws Exception {
    Flow flow = new FlowBuilder<Flow>("subflow").from(step1).end();
    SimpleJobBuilder builder = new JobBuilder("flow").repository(jobRepository).start(step2);
    builder.split(new SimpleAsyncTaskExecutor()).add(flow).end();
    builder.preventRestart().build().execute(execution);
    assertEquals(BatchStatus.COMPLETED, execution.getStatus());
    assertEquals(2, execution.getStepExecutions().size());
View Full Code Here

  @Test
  public void testBasicHandling() throws Exception {

    Collection<Flow> flows  = new ArrayList<Flow>();
    Flow flow1 = mock(Flow.class);
    Flow flow2 = mock(Flow.class);
    flows.add(flow1);
    flows.add(flow2);

    SplitState state = new SplitState(flows, "foo");

    when(flow1.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));
    when(flow2.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));

    FlowExecutionStatus result = state.handle(executor);
    assertEquals(FlowExecutionStatus.COMPLETED, result);

  }
View Full Code Here

  }

  @Test
  public void testConcurrentHandling() throws Exception {

    Flow flow1 = mock(Flow.class);
    Flow flow2 = mock(Flow.class);

    SplitState state = new SplitState(Arrays.asList(flow1, flow2), "foo");
    state.setTaskExecutor(new SimpleAsyncTaskExecutor());

    when(flow1.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));
    when(flow2.start(executor)).thenReturn(new FlowExecution("step1", FlowExecutionStatus.COMPLETED));
    FlowExecutionStatus result = state.handle(executor);
    assertEquals(FlowExecutionStatus.COMPLETED, result);

  }
View Full Code Here

          throw new JobExecutionException("Decision step is an invalid first step");
        } else {
          break;
        }
      } else if(startState instanceof FlowState){
        Flow firstFlow = ((FlowState) startState).getFlows().iterator().next();
        startState = firstFlow.getStates().iterator().next();
      } else {
        break;
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.job.flow.Flow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.