// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/Action.java
// public interface Action {
//     public void doSomething();
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/ServiceProvider.java
// public class ServiceProvider
//         implements ScopedServices {
//     @Override
//     public void bindServices(@Nonnull ServiceBinder serviceBinder) {
//         Object key = serviceBinder.getKey();
//         if(key instanceof HasServices) {
//             ((HasServices) key).bindServices(serviceBinder);
//             return;
//         }
//         if(key instanceof HasParentServices) {
//             ((HasParentServices) key).bindServices(serviceBinder);
//             //noinspection UnnecessaryReturnStatement
//             return;
//         }
//     }
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/TestKeyWithExplicitParent.java
// public abstract class TestKeyWithExplicitParent extends TestKeyWithScope implements HasParentServices {
//     public TestKeyWithExplicitParent(String name) {
//         super(name);
//     }
// 
//     protected TestKeyWithExplicitParent(Parcel in) {
//         super(in);
//     }
// 
//     @Override
//     public final void bindServices(ServiceBinder serviceBinder) {
//         if(name.equals(serviceBinder.getScopeTag())) {
//             bindOwnServices(serviceBinder);
//         } else {
//             bindParentServices(serviceBinder);
//         }
//     }
// 
//     protected abstract void bindParentServices(ServiceBinder serviceBinder);
// 
//     protected abstract void bindOwnServices(ServiceBinder serviceBinder);
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/TestKeyWithScope.java
// public abstract class TestKeyWithScope
//         extends TestKey
//         implements HasServices {
//     public TestKeyWithScope(String name) {
//         super(name);
//     }
// 
//     protected TestKeyWithScope(Parcel in) {
//         super(in);
//     }
// 
//     @Nonnull
//     @Override
//     public String getScopeTag() {
//         return name;
//     }
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/AssertionHelper.java
// public static void assertThrows(Action action) {
//     try {
//         action.doSomething();
//         Assert.fail("Did not throw exception.");
//     } catch(Exception e) {
//         // OK!
//     }
// }


import com.zhuinden.simplestack.helpers.Action;
import com.zhuinden.simplestack.helpers.ServiceProvider;
import com.zhuinden.simplestack.helpers.TestKeyWithExplicitParent;
import com.zhuinden.simplestack.helpers.TestKeyWithScope;
import com.zhuinden.statebundle.StateBundle;
import org.junit.Test;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static com.zhuinden.simplestack.helpers.AssertionHelper.assertThrows;
import static org.assertj.core.api.Assertions.assertThat;

        // then
        assertThat(backstack.hasService(GlobalServices.SCOPE_TAG, "service0")).isTrue();
        assertThat(backstack.hasService(GlobalServices.SCOPE_TAG, "alias0")).isTrue();

        assertThat(backstack.canFindFromScope(GlobalServices.SCOPE_TAG, "alias0")).isTrue();
        assertThat(backstack.canFindFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.ALL)).isTrue();
        assertThat(backstack.canFindFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.EXPLICIT)).isTrue();
        assertThat(backstack.canFindService("alias0")).isTrue();

        assertThat(backstack.lookupFromScope(GlobalServices.SCOPE_TAG, "alias0")).isSameAs(service0);
        assertThat(backstack.lookupFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.ALL)).isSameAs(service0);
        assertThat(backstack.lookupFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.EXPLICIT)).isSameAs(service0);
        assertThat(backstack.lookupService("alias0")).isSameAs(service0);

        // ALSO

        backstack.goBack();

        backstack.goBack();

        // then
        assertThat(backstack.hasService("parent1", "serviceP1")).isFalse();
        assertThat(backstack.hasService("parent1", "aliasP1")).isFalse();

        assertThat(backstack.canFindFromScope("parent1", "aliasP1")).isFalse();
        assertThat(backstack.canFindFromScope("parent1", "aliasP1", ScopeLookupMode.ALL)).isFalse();
        assertThat(backstack.canFindFromScope("parent1", "aliasP1", ScopeLookupMode.EXPLICIT)).isFalse();
        assertThat(backstack.canFindService("aliasP1")).isFalse();

// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/Action.java
// public interface Action {
//     public void doSomething();
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/ServiceProvider.java
// public class ServiceProvider
//         implements ScopedServices {
//     @Override
//     public void bindServices(@Nonnull ServiceBinder serviceBinder) {
//         Object key = serviceBinder.getKey();
//         if(key instanceof HasServices) {
//             ((HasServices) key).bindServices(serviceBinder);
//             return;
//         }
//         if(key instanceof HasParentServices) {
//             ((HasParentServices) key).bindServices(serviceBinder);
//             //noinspection UnnecessaryReturnStatement
//             return;
//         }
//     }
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/TestKeyWithExplicitParent.java
// public abstract class TestKeyWithExplicitParent extends TestKeyWithScope implements HasParentServices {
//     public TestKeyWithExplicitParent(String name) {
//         super(name);
//     }
// 
//     protected TestKeyWithExplicitParent(Parcel in) {
//         super(in);
//     }
// 
//     @Override
//     public final void bindServices(ServiceBinder serviceBinder) {
//         if(name.equals(serviceBinder.getScopeTag())) {
//             bindOwnServices(serviceBinder);
//         } else {
//             bindParentServices(serviceBinder);
//         }
//     }
// 
//     protected abstract void bindParentServices(ServiceBinder serviceBinder);
// 
//     protected abstract void bindOwnServices(ServiceBinder serviceBinder);
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/TestKeyWithScope.java
// public abstract class TestKeyWithScope
//         extends TestKey
//         implements HasServices {
//     public TestKeyWithScope(String name) {
//         super(name);
//     }
// 
//     protected TestKeyWithScope(Parcel in) {
//         super(in);
//     }
// 
//     @Nonnull
//     @Override
//     public String getScopeTag() {
//         return name;
//     }
// }
// 
// Path: simple-stack/src/test/java/com/zhuinden/simplestack/helpers/AssertionHelper.java
// public static void assertThrows(Action action) {
//     try {
//         action.doSomething();
//         Assert.fail("Did not throw exception.");
//     } catch(Exception e) {
//         // OK!
//     }
// }


// Path: simple-stack/src/test/java/com/zhuinden/simplestack/ScopingAliasTest.java
import com.zhuinden.simplestack.helpers.Action;
import com.zhuinden.simplestack.helpers.ServiceProvider;
import com.zhuinden.simplestack.helpers.TestKeyWithExplicitParent;
import com.zhuinden.simplestack.helpers.TestKeyWithScope;
import com.zhuinden.statebundle.StateBundle;
import org.junit.Test;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static com.zhuinden.simplestack.helpers.AssertionHelper.assertThrows;
import static org.assertj.core.api.Assertions.assertThat;


        // then
        assertThat(backstack.hasService(GlobalServices.SCOPE_TAG, "service0")).isTrue();
        assertThat(backstack.hasService(GlobalServices.SCOPE_TAG, "alias0")).isTrue();

        assertThat(backstack.canFindFromScope(GlobalServices.SCOPE_TAG, "alias0")).isTrue();
        assertThat(backstack.canFindFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.ALL)).isTrue();
        assertThat(backstack.canFindFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.EXPLICIT)).isTrue();
        assertThat(backstack.canFindService("alias0")).isTrue();

        assertThat(backstack.lookupFromScope(GlobalServices.SCOPE_TAG, "alias0")).isSameAs(service0);
        assertThat(backstack.lookupFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.ALL)).isSameAs(service0);
        assertThat(backstack.lookupFromScope(GlobalServices.SCOPE_TAG, "alias0", ScopeLookupMode.EXPLICIT)).isSameAs(service0);
        assertThat(backstack.lookupService("alias0")).isSameAs(service0);

        // ALSO

        backstack.goBack();

        backstack.goBack();

        // then
        assertThat(backstack.hasService("parent1", "serviceP1")).isFalse();
        assertThat(backstack.hasService("parent1", "aliasP1")).isFalse();

        assertThat(backstack.canFindFromScope("parent1", "aliasP1")).isFalse();
        assertThat(backstack.canFindFromScope("parent1", "aliasP1", ScopeLookupMode.ALL)).isFalse();
        assertThat(backstack.canFindFromScope("parent1", "aliasP1", ScopeLookupMode.EXPLICIT)).isFalse();
        assertThat(backstack.canFindService("aliasP1")).isFalse();

        assertThrows(new Action() {