// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
//   return new SimpleRepository<>(object);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> REventSource<T, T> repositoryWithInitialValue(@NonNull final T initialValue) {
//   return RepositoryCompiler.repositoryWithInitialValue(initialValue);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
//   return failure == ABSENT_THROWABLE
//       ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
//   return new Result<>(checkNotNull(value), null);
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/SupplierGives.java
// @NonNull
// @Factory
// public static <T> Matcher<Supplier<T>> has(@NonNull final T value) {
//   return new SupplierGives<>(value);
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
//   return WAS_NOT_UPDATED;
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
//   return WAS_UPDATED;
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
//   return new MockUpdatable();
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
//   private final List<Observable> observables;
// 
//   private boolean updated;
// 
//   private MockUpdatable() {
//     this.observables = new ArrayList<>();
//     this.updated = false;
//   }
// 
//   @NonNull
//   public static MockUpdatable mockUpdatable() {
//     return new MockUpdatable();
//   }
// 
//   @Override
//   public void update() {
//     updated = true;
//   }
// 
//   public boolean wasUpdated() {
//     runUiThreadTasksIncludingDelayedTasks();
//     return updated;
//   }
// 
//   public void resetUpdated() {
//     runUiThreadTasksIncludingDelayedTasks();
//     updated = false;
//   }
// 
//   public void addToObservable(@NonNull final Observable observable) {
//     observable.addUpdatable(this);
//     observables.add(observable);
//     runUiThreadTasksIncludingDelayedTasks();
//   }
// 
//   public void removeFromObservables() {
//     for (final Observable observable : observables) {
//       observable.removeUpdatable(this);
//     }
//     observables.clear();
//   }
// }


import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repositoryWithInitialValue;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.SupplierGives.has;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.anyListOf;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
    when(mockPredicate.apply(anyListOf(Integer.class))).thenReturn(true);
    when(mockPredicate.apply(INITIAL_LIST)).thenReturn(false);

    final Repository<List<Integer>> repository = repositoryWithInitialValue(INITIAL_LIST)
        .observe()
        .onUpdatesPerLoop()
        .check(mockPredicate).orSkip()
        .thenGetFrom(otherListSource)
        .compile();

    updatable.addToObservable(repository);

    assertThat(repository, has(INITIAL_LIST));
    assertThat(updatable, wasNotUpdated());
  }

  @Test
  public void shouldNotSkipAfterPassedCheck() {
    when(mockPredicate.apply(anyListOf(Integer.class))).thenReturn(true);

    final Repository<List<Integer>> repository = repositoryWithInitialValue(INITIAL_LIST)
        .observe()
        .onUpdatesPerLoop()
        .check(mockPredicate).orSkip()
        .thenGetFrom(listSource)
        .compile();

    updatable.addToObservable(repository);

    assertThat(repository, has(LIST));
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> MutableRepository<T> mutableRepository(@NonNull final T object) {
//   return new SimpleRepository<>(object);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Repositories.java
// @NonNull
// public static <T> REventSource<T, T> repositoryWithInitialValue(@NonNull final T initialValue) {
//   return RepositoryCompiler.repositoryWithInitialValue(initialValue);
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> failure(@NonNull final Throwable failure) {
//   return failure == ABSENT_THROWABLE
//       ? Result.<T>absent() : new Result<T>(null, checkNotNull(failure));
// }
// 
// Path: agera/src/main/java/com/google/android/agera/Result.java
// @NonNull
// public static <T> Result<T> success(@NonNull final T value) {
//   return new Result<>(checkNotNull(value), null);
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/SupplierGives.java
// @NonNull
// @Factory
// public static <T> Matcher<Supplier<T>> has(@NonNull final T value) {
//   return new SupplierGives<>(value);
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasNotUpdated() {
//   return WAS_NOT_UPDATED;
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/matchers/UpdatableUpdated.java
// @NonNull
// @Factory
// public static UpdatableUpdated wasUpdated() {
//   return WAS_UPDATED;
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// @NonNull
// public static MockUpdatable mockUpdatable() {
//   return new MockUpdatable();
// }
// 
// Path: agera/src/test/java/com/google/android/agera/test/mocks/MockUpdatable.java
// public final class MockUpdatable implements Updatable {
//   private final List<Observable> observables;
// 
//   private boolean updated;
// 
//   private MockUpdatable() {
//     this.observables = new ArrayList<>();
//     this.updated = false;
//   }
// 
//   @NonNull
//   public static MockUpdatable mockUpdatable() {
//     return new MockUpdatable();
//   }
// 
//   @Override
//   public void update() {
//     updated = true;
//   }
// 
//   public boolean wasUpdated() {
//     runUiThreadTasksIncludingDelayedTasks();
//     return updated;
//   }
// 
//   public void resetUpdated() {
//     runUiThreadTasksIncludingDelayedTasks();
//     updated = false;
//   }
// 
//   public void addToObservable(@NonNull final Observable observable) {
//     observable.addUpdatable(this);
//     observables.add(observable);
//     runUiThreadTasksIncludingDelayedTasks();
//   }
// 
//   public void removeFromObservables() {
//     for (final Observable observable : observables) {
//       observable.removeUpdatable(this);
//     }
//     observables.clear();
//   }
// }


// Path: agera/src/test/java/com/google/android/agera/RepositoryTerminationTest.java
import static com.google.android.agera.Repositories.mutableRepository;
import static com.google.android.agera.Repositories.repositoryWithInitialValue;
import static com.google.android.agera.Result.failure;
import static com.google.android.agera.Result.success;
import static com.google.android.agera.test.matchers.SupplierGives.has;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasNotUpdated;
import static com.google.android.agera.test.matchers.UpdatableUpdated.wasUpdated;
import static com.google.android.agera.test.mocks.MockUpdatable.mockUpdatable;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Matchers.anyListOf;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.robolectric.annotation.Config.NONE;
import com.google.android.agera.test.mocks.MockUpdatable;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

    when(mockPredicate.apply(anyListOf(Integer.class))).thenReturn(true);
    when(mockPredicate.apply(INITIAL_LIST)).thenReturn(false);

    final Repository<List<Integer>> repository = repositoryWithInitialValue(INITIAL_LIST)
        .observe()
        .onUpdatesPerLoop()
        .check(mockPredicate).orSkip()
        .thenGetFrom(otherListSource)
        .compile();

    updatable.addToObservable(repository);

    assertThat(repository, has(INITIAL_LIST));
    assertThat(updatable, wasNotUpdated());
  }

  @Test
  public void shouldNotSkipAfterPassedCheck() {
    when(mockPredicate.apply(anyListOf(Integer.class))).thenReturn(true);

    final Repository<List<Integer>> repository = repositoryWithInitialValue(INITIAL_LIST)
        .observe()
        .onUpdatesPerLoop()
        .check(mockPredicate).orSkip()
        .thenGetFrom(listSource)
        .compile();

    updatable.addToObservable(repository);

    assertThat(repository, has(LIST));
    assertThat(updatable, wasUpdated());