// 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/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 com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*
 * 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;



public class PaginatedQueryMapperTests {

  public static final String FAKE_PAGINATED_QUERY_ID = "fake.paginated.query.id";
  public static final int FAKE_OFFSET = 0;
  public static final int FAKE_LIMIT = 10;

  private PaginatedQueryMapper mapper;

  @Before public void setUp() throws Exception {
    mapper = new PaginatedQueryMapper();
  }

  @Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
  public void shouldThrowIllegalArgumentExceptionIfMappingToStringWithNullValue() {
    mapper.toString(null);
  }

  @Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
  public void shouldThrowIllegalArgumentExceptionIfMappingFromStringWithNullValue() {
    mapper.fromString(null);
  }

  @Test public void shouldMappingToPaginatedQueryToStringValue() throws Exception {
    String value = mapper.toString(givenAFakePaginatedQuery());

    assertThat(value).isNotNull();
    assertThat(value).isEqualTo(FAKE_PAGINATED_QUERY_ID + "_" + FAKE_OFFSET + "_" + FAKE_LIMIT);
  }

  @Test public void shouldMappingFromStringToPaginatedQuery() throws Exception {
// 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/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/test/java/com/mobilejazz/cacheio/PaginatedQueryMapperTests.java
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;

/*
 * 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;



public class PaginatedQueryMapperTests {

  public static final String FAKE_PAGINATED_QUERY_ID = "fake.paginated.query.id";
  public static final int FAKE_OFFSET = 0;
  public static final int FAKE_LIMIT = 10;

  private PaginatedQueryMapper mapper;

  @Before public void setUp() throws Exception {
    mapper = new PaginatedQueryMapper();
  }

  @Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
  public void shouldThrowIllegalArgumentExceptionIfMappingToStringWithNullValue() {
    mapper.toString(null);
  }

  @Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
  public void shouldThrowIllegalArgumentExceptionIfMappingFromStringWithNullValue() {
    mapper.fromString(null);
  }

  @Test public void shouldMappingToPaginatedQueryToStringValue() throws Exception {
    String value = mapper.toString(givenAFakePaginatedQuery());

    assertThat(value).isNotNull();
    assertThat(value).isEqualTo(FAKE_PAGINATED_QUERY_ID + "_" + FAKE_OFFSET + "_" + FAKE_LIMIT);
  }

  @Test public void shouldMappingFromStringToPaginatedQuery() throws Exception {
    PaginatedQuery query =