// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
// 
//   @Override public String toString(DefaultQuery model) {
//     checkArgument(model, "DefaultQuery == null");
//     return model.getId();
//   }
// 
//   @Override public DefaultQuery fromString(String str) {
//     checkArgument(str, "DefaultQuery string value == null");
//     return new DefaultQuery(str);
//   }
// }
// 
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
// 
//   private final static String DELIMITER = "_";
// 
//   @Override public String toString(PaginatedQuery model) {
//     checkArgument(model, "PaginatedQuery == null");
//     return String.valueOf(model.getId() + DELIMITER + model.getOffset())
//         + DELIMITER
//         + model.getLimit();
//   }
// 
//   @Override public PaginatedQuery fromString(String str) {
//     checkArgument(str, "PaginatedQuery string value == null");
//     String[] tokens = str.split(DELIMITER);
//     String id = tokens[0];
//     String offset = tokens[1];
//     String limit = tokens[2];
//     return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
//   }
// }
// 
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
// 
//   private String id;
//   private String name;
// 
//   public TestUser(String id, String name) {
//     this.id = id;
//     this.name = name;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   @Override public String getId() {
//     return this.id;
//   }
// }
// 
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
// 
//   private final String id;
// 
//   public DefaultQuery(String id) {
//     this.id = id;
//   }
// 
//   @Override public String getId() {
//     return this.id;
//   }
// 
//   @Override public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     DefaultQuery query = (DefaultQuery) o;
// 
//     return !(id != null ? !id.equals(query.id) : query.id != null);
// 
//   }
// 
//   @Override public int hashCode() {
//     return id != null ? id.hashCode() : 0;
//   }
// }
// 
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
// 
//   private final String id;
//   private final int offset;
//   private final int limit;
// 
//   public PaginatedQuery(String id, int offset, int limit) {
//     this.id = id;
//     this.offset = offset;
//     this.limit = limit;
//   }
// 
//   public int getOffset() {
//     return offset;
//   }
// 
//   public int getLimit() {
//     return limit;
//   }
// 
//   @Override public String getId() {
//     return id;
//   }
// 
//   @Override public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     PaginatedQuery that = (PaginatedQuery) o;
// 
//     if (offset != that.offset) return false;
//     if (limit != that.limit) return false;
//     return id.equals(that.id);
// 
//   }
// 
//   @Override public int hashCode() {
//     int result = id.hashCode();
//     result = 31 * result + offset;
//     result = 31 * result + limit;
//     return result;
//   }
// }


import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*;
/*
 * Copyright (C) 2016 Mobile Jazz
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.mobilejazz.cacheio;




@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {

  private CacheIO cacheIO;
  public static final String FAKE_TEST_USER_ID = "fake.user.id";
  public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";

  @Before public void setUp() throws Exception {
    this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
        .identifier("test.database")
        .executor(Executors.newSingleThreadExecutor())
        .setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper())
        .setKeyMapper(DefaultQuery.class, new DefaultQueryMapper())
        .build();
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowAExceptionWhenCacheAndQueryCacheIsNull() throws Exception {
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
// 
//   @Override public String toString(DefaultQuery model) {
//     checkArgument(model, "DefaultQuery == null");
//     return model.getId();
//   }
// 
//   @Override public DefaultQuery fromString(String str) {
//     checkArgument(str, "DefaultQuery string value == null");
//     return new DefaultQuery(str);
//   }
// }
// 
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
// 
//   private final static String DELIMITER = "_";
// 
//   @Override public String toString(PaginatedQuery model) {
//     checkArgument(model, "PaginatedQuery == null");
//     return String.valueOf(model.getId() + DELIMITER + model.getOffset())
//         + DELIMITER
//         + model.getLimit();
//   }
// 
//   @Override public PaginatedQuery fromString(String str) {
//     checkArgument(str, "PaginatedQuery string value == null");
//     String[] tokens = str.split(DELIMITER);
//     String id = tokens[0];
//     String offset = tokens[1];
//     String limit = tokens[2];
//     return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
//   }
// }
// 
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
// 
//   private String id;
//   private String name;
// 
//   public TestUser(String id, String name) {
//     this.id = id;
//     this.name = name;
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   @Override public String getId() {
//     return this.id;
//   }
// }
// 
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
// 
//   private final String id;
// 
//   public DefaultQuery(String id) {
//     this.id = id;
//   }
// 
//   @Override public String getId() {
//     return this.id;
//   }
// 
//   @Override public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     DefaultQuery query = (DefaultQuery) o;
// 
//     return !(id != null ? !id.equals(query.id) : query.id != null);
// 
//   }
// 
//   @Override public int hashCode() {
//     return id != null ? id.hashCode() : 0;
//   }
// }
// 
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
// 
//   private final String id;
//   private final int offset;
//   private final int limit;
// 
//   public PaginatedQuery(String id, int offset, int limit) {
//     this.id = id;
//     this.offset = offset;
//     this.limit = limit;
//   }
// 
//   public int getOffset() {
//     return offset;
//   }
// 
//   public int getLimit() {
//     return limit;
//   }
// 
//   @Override public String getId() {
//     return id;
//   }
// 
//   @Override public boolean equals(Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     PaginatedQuery that = (PaginatedQuery) o;
// 
//     if (offset != that.offset) return false;
//     if (limit != that.limit) return false;
//     return id.equals(that.id);
// 
//   }
// 
//   @Override public int hashCode() {
//     int result = id.hashCode();
//     result = 31 * result + offset;
//     result = 31 * result + limit;
//     return result;
//   }
// }


// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*;

/*
 * Copyright (C) 2016 Mobile Jazz
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.mobilejazz.cacheio;




@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {

  private CacheIO cacheIO;
  public static final String FAKE_TEST_USER_ID = "fake.user.id";
  public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";

  @Before public void setUp() throws Exception {
    this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
        .identifier("test.database")
        .executor(Executors.newSingleThreadExecutor())
        .setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper())
        .setKeyMapper(DefaultQuery.class, new DefaultQueryMapper())
        .build();
  }

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowAExceptionWhenCacheAndQueryCacheIsNull() throws Exception {
    new StringKeyedRxRepository.Builder<TestUser, DefaultQuery>().setCache(null)