@@ -0,0 +1,2466 @@
+package arez.integration.action;%0A%0Aimport arez.Arez;%0Aimport arez.ArezContext;%0Aimport arez.Environment;%0Aimport arez.Function;%0Aimport arez.SafeFunction;%0Aimport arez.annotations.Action;%0Aimport arez.annotations.ArezComponent;%0Aimport arez.integration.AbstractArezIntegrationTest;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.concurrent.atomic.AtomicInteger;%0Aimport javax.annotation.Nonnull;%0Aimport org.testng.annotations.Test;%0Aimport static org.testng.Assert.*;%0A%0A@SuppressWarnings( %7B %22UnusedReturnValue%22, %22unused%22, %22SameParameterValue%22 %7D )%0Apublic class RequiresEnvironmentTest%0A  extends AbstractArezIntegrationTest%0A%7B%0A  @ArezComponent%0A  static abstract class MyComponent%0A  %7B%0A    private final ArrayList%3CString%3E _steps;%0A%0A    MyComponent( @Nonnull final ArrayList%3CString%3E steps )%0A    %7B%0A      _steps = steps;%0A    %7D%0A%0A    @Action( requireEnvironment = true, verifyRequired = false )%0A    void myAction()%0A    %7B%0A      _steps.add( %22myAction%22 );%0A    %7D%0A%0A    @Action( requireEnvironment = false, verifyRequired = false )%0A    void myOtherAction()%0A    %7B%0A      _steps.add( %22myOtherAction%22 );%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void scenario()%0A  %7B%0A    final ArezContext context = Arez.context();%0A%0A    // Scheduler paused otherwise reactions will run in environment and upset our environment call count%0A    context.pauseScheduler();%0A%0A    final ArrayList%3CString%3E steps = new ArrayList%3C%3E();%0A    final AtomicInteger inEnvironmentCallCount = new AtomicInteger();%0A    context.setEnvironment( new Environment()%0A    %7B%0A      @Override%0A      public %3CT%3E T run( @Nonnull final SafeFunction%3CT%3E function )%0A      %7B%0A        try%0A        %7B%0A          steps.add( %22EnvironmentStart%22 );%0A          return function.call();%0A        %7D%0A        finally%0A        %7B%0A          steps.add( %22EnvironmentEnd%22 );%0A        %7D%0A      %7D%0A%0A      @Override%0A      public %3CT%3E T run( @Nonnull final Function%3CT%3E function )%0A        throws Throwable%0A      %7B%0A        try%0A        %7B%0A          steps.add( %22EnvironmentStart%22 );%0A          return function.call();%0A        %7D%0A        finally%0A        %7B%0A          steps.add( %22EnvironmentEnd%22 );%0A        %7D%0A      %7D%0A    %7D );%0A%0A    final MyComponent component = new RequiresEnvironmentTest_Arez_MyComponent( steps );%0A%0A    component.myAction();%0A%0A    assertEquals( steps, Arrays.asList( %22EnvironmentStart%22, %22myAction%22, %22EnvironmentEnd%22 ) );%0A%0A    component.myOtherAction();%0A%0A    assertEquals( steps, Arrays.asList( %22EnvironmentStart%22, %22myAction%22, %22EnvironmentEnd%22, %22myOtherAction%22 ) );%0A  %7D%0A%7D%0A

Add integration test for actions that switch to environments