executor.close(new FlowExecution(stateName, status)); throw e; executor.close(new FlowExecution(stateName, status)); throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name, stateName), e); FlowExecution result = new FlowExecution(stateName, status); executor.close(result); return result;
@Test public void testBasicHandling() throws Exception { Collection<Flow> flows = new ArrayList<>(); 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); }
@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); }
@Test public void testEnumOrdering() throws Exception { FlowExecution first = new FlowExecution("foo", FlowExecutionStatus.COMPLETED); FlowExecution second = new FlowExecution("foo", FlowExecutionStatus.FAILED); assertTrue("Should be negative",first.compareTo(second)<0); assertTrue("Should be positive",second.compareTo(first)>0); }
@Test public void testFailed() throws Exception { FlowExecution first = new FlowExecution("foo", FlowExecutionStatus.COMPLETED); FlowExecution second = new FlowExecution("foo", FlowExecutionStatus.FAILED); assertTrue("Should be negative", first.compareTo(second)<0); assertTrue("Should be positive", second.compareTo(first)>0); assertEquals(FlowExecutionStatus.FAILED, aggregator.aggregate(Arrays.asList(first, second))); }
@Test public void testEnumStartsWithOrdering() throws Exception { FlowExecution first = new FlowExecution("foo", new FlowExecutionStatus("COMPLETED.BAR")); FlowExecution second = new FlowExecution("foo", new FlowExecutionStatus("FAILED.FOO")); assertTrue("Should be negative",first.compareTo(second)<0); assertTrue("Should be positive",second.compareTo(first)>0); }
@Test public void testEnumAndAlpha() throws Exception { FlowExecution first = new FlowExecution("foo", new FlowExecutionStatus("ZZZZZ")); FlowExecution second = new FlowExecution("foo", new FlowExecutionStatus("FAILED.FOO")); assertTrue("Should be negative",first.compareTo(second)<0); assertTrue("Should be positive",second.compareTo(first)>0); }
@Test public void testEnumStartsWithAlphaOrdering() throws Exception { FlowExecution first = new FlowExecution("foo", new FlowExecutionStatus("COMPLETED.BAR")); FlowExecution second = new FlowExecution("foo", new FlowExecutionStatus("COMPLETED.FOO")); assertTrue("Should be negative",first.compareTo(second)<0); assertTrue("Should be positive",second.compareTo(first)>0); }
@Test public void testAlphaOrdering() throws Exception { FlowExecution first = new FlowExecution("foo", new FlowExecutionStatus("BAR")); FlowExecution second = new FlowExecution("foo", new FlowExecutionStatus("SPAM")); assertTrue("Should be negative",first.compareTo(second)<0); assertTrue("Should be positive",second.compareTo(first)>0); }
@Test public void testBasicProperties() throws Exception { FlowExecution execution = new FlowExecution("foo", new FlowExecutionStatus("BAR")); assertEquals("foo",execution.getName()); assertEquals("BAR",execution.getStatus().getName()); }
executor.close(new FlowExecution(stateName, status)); throw e; executor.close(new FlowExecution(stateName, status)); throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name, stateName), e); FlowExecution result = new FlowExecution(stateName, status); executor.close(result); return result;
executor.close(new FlowExecution(stateName, status)); throw e; executor.close(new FlowExecution(stateName, status)); throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name, stateName), e); FlowExecution result = new FlowExecution(stateName, status); executor.close(result); return result;
executor.close(new FlowExecution(stateName, status)); throw e; executor.close(new FlowExecution(stateName, status)); throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name, stateName), e); FlowExecution result = new FlowExecution(stateName, status); executor.close(result); return result;
executor.close(new FlowExecution(stateName, status)); throw e; executor.close(new FlowExecution(stateName, status)); throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name, stateName), e); FlowExecution result = new FlowExecution(stateName, status); executor.close(result); return result;