@@ -0,0 +1,2815 @@
+/*-%0A * -%5C-%5C-%0A * Flo Workflow Definition%0A * --%0A * Copyright (C) 2016 - 2018 Spotify AB%0A * --%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * -/-/-%0A */%0A%0Apackage com.spotify.flo.context;%0A%0Aimport static java.util.concurrent.TimeUnit.SECONDS;%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.never;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport com.spotify.flo.EvalContext;%0Aimport com.spotify.flo.EvalContext.Value;%0Aimport com.spotify.flo.Task;%0Aimport com.spotify.flo.TaskBuilder.F0;%0Aimport com.spotify.flo.TaskOperator;%0Aimport com.spotify.flo.TaskOperator.OperationException;%0Aimport java.util.concurrent.CompletableFuture;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0A%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class OperatingContextTest %7B%0A%0A  @Mock OperationException operationException;%0A  @Mock F0%3CString%3E spec;%0A  @Mock TaskOperator%3CF0%3CString%3E%3E operator;%0A%0A  private final EvalContext operatingContext = OperatingContext.composeWith(EvalContext.sync());%0A%0A  private Task%3CString%3E task;%0A%0A  @Before%0A  public void setUp() %7B%0A    when(operator.provide(any())).thenReturn(spec);%0A    task = Task.named(%22task%22)%0A        .ofType(String.class)%0A        .context(operator)%0A        .process(F0::get);%0A  %7D%0A%0A  @Test%0A  public void shouldRunOperationException() throws Exception %7B%0A    when(spec.get()).thenThrow(operationException);%0A    when(operationException.run()).thenReturn(%22foo%22);%0A    final String result = future(operatingContext.evaluate(task)).get(30, SECONDS);%0A    assertThat(result, is(%22foo%22));%0A    verify(operationException).run();%0A  %7D%0A%0A  @Test%0A  public void shouldReturnValueDirectly() throws Exception %7B%0A    when(spec.get()).thenReturn(%22bar%22);%0A    final String result = future(operatingContext.evaluate(task)).get(30, SECONDS);%0A    assertThat(result, is(%22bar%22));%0A    verify(operationException, never()).run();%0A  %7D%0A%0A  private CompletableFuture%3CString%3E future(Value%3CString%3E v) %7B%0A    final CompletableFuture%3CString%3E future = new CompletableFuture%3C%3E();%0A    v.consume(future::complete);%0A    v.onFail(future::completeExceptionally);%0A    return future;%0A  %7D%0A%7D

add test