// Path: hazelcast-spring-data-query/src/main/java/org/littlewings/hazelcast/spring/entity/Book.java
// @KeySpace("books")
// public class Book implements Serializable {
//     private static final long serialVersionUID = 1L;
// 
//     @Id
//     private String isbn;
//     private String title;
//     private int price;
// 
//     public static Book create(String isbn, String title, int price) {
//         Book book = new Book();
//         book.setIsbn(isbn);
//         book.setTitle(title);
//         book.setPrice(price);
// 
//         return book;
//     }
// 
//     public String getIsbn() {
//         return isbn;
//     }
// 
//     public void setIsbn(String isbn) {
//         this.isbn = isbn;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public int getPrice() {
//         return price;
//     }
// 
//     public void setPrice(int price) {
//         this.price = price;
//     }
// }
// 
// Path: hazelcast-spring-data/src/main/java/org/littlewings/hazelcast/spring/repository/BookRepository.java
// public interface BookRepository extends HazelcastRepository<Book, String> {
//     Book findByTitle(String title);
// 
//     List<Book> findByPriceGreaterThan(int price);
// }


import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.littlewings.hazelcast.spring.entity.Book;
import org.littlewings.hazelcast.spring.repository.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
        withOtherHazelcastInstances(2, () -> {
            bookRepository.save(books);

            List<Book> resultBooks = bookRepository.findByTitle(books.get(0).getTitle());

            assertThat(resultBooks).hasSize(1);
            assertThat(resultBooks.get(0).getIsbn()).isEqualTo("978-1785285332");
            assertThat(resultBooks.get(0).getTitle()).isEqualTo("Getting Started With Hazelcast");
        });
    }

    @Test
    public void greaterThanQuery() {
        withOtherHazelcastInstances(2, () -> {
            bookRepository.save(books);

            List<Book> resultBooks = bookRepository.findByPriceGreaterThan(4000);

            assertThat(resultBooks).hasSize(2);
            assertThat(resultBooks.get(0).getIsbn()).isEqualTo("978-4798142470");
            assertThat(resultBooks.get(0).getTitle()).isEqualTo("Spring徹底入門 Spring FrameworkによるJavaアプリケーション開発");
            assertThat(resultBooks.get(0).getPrice()).isEqualTo(4320);
            assertThat(resultBooks.get(1).getIsbn()).isEqualTo("978-4774182179");
            assertThat(resultBooks.get(1).getTitle()).isEqualTo("［改訂新版］Spring入門 ――Javaフレームワーク・より良い設計とアーキテクチャ");
            assertThat(resultBooks.get(1).getPrice()).isEqualTo(4104);
        });
    }

    @Test
    public void andQuery() {
// Path: hazelcast-spring-data-query/src/main/java/org/littlewings/hazelcast/spring/entity/Book.java
// @KeySpace("books")
// public class Book implements Serializable {
//     private static final long serialVersionUID = 1L;
// 
//     @Id
//     private String isbn;
//     private String title;
//     private int price;
// 
//     public static Book create(String isbn, String title, int price) {
//         Book book = new Book();
//         book.setIsbn(isbn);
//         book.setTitle(title);
//         book.setPrice(price);
// 
//         return book;
//     }
// 
//     public String getIsbn() {
//         return isbn;
//     }
// 
//     public void setIsbn(String isbn) {
//         this.isbn = isbn;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public int getPrice() {
//         return price;
//     }
// 
//     public void setPrice(int price) {
//         this.price = price;
//     }
// }
// 
// Path: hazelcast-spring-data/src/main/java/org/littlewings/hazelcast/spring/repository/BookRepository.java
// public interface BookRepository extends HazelcastRepository<Book, String> {
//     Book findByTitle(String title);
// 
//     List<Book> findByPriceGreaterThan(int price);
// }


// Path: hazelcast-spring-data-query/src/test/java/org/littlewings/hazelcast/spring/SpringDataHazelcastTest.java
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.littlewings.hazelcast.spring.entity.Book;
import org.littlewings.hazelcast.spring.repository.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;

        withOtherHazelcastInstances(2, () -> {
            bookRepository.save(books);

            List<Book> resultBooks = bookRepository.findByTitle(books.get(0).getTitle());

            assertThat(resultBooks).hasSize(1);
            assertThat(resultBooks.get(0).getIsbn()).isEqualTo("978-1785285332");
            assertThat(resultBooks.get(0).getTitle()).isEqualTo("Getting Started With Hazelcast");
        });
    }

    @Test
    public void greaterThanQuery() {
        withOtherHazelcastInstances(2, () -> {
            bookRepository.save(books);

            List<Book> resultBooks = bookRepository.findByPriceGreaterThan(4000);

            assertThat(resultBooks).hasSize(2);
            assertThat(resultBooks.get(0).getIsbn()).isEqualTo("978-4798142470");
            assertThat(resultBooks.get(0).getTitle()).isEqualTo("Spring徹底入門 Spring FrameworkによるJavaアプリケーション開発");
            assertThat(resultBooks.get(0).getPrice()).isEqualTo(4320);
            assertThat(resultBooks.get(1).getIsbn()).isEqualTo("978-4774182179");
            assertThat(resultBooks.get(1).getTitle()).isEqualTo("［改訂新版］Spring入門 ――Javaフレームワーク・より良い設計とアーキテクチャ");
            assertThat(resultBooks.get(1).getPrice()).isEqualTo(4104);
        });
    }

    @Test
    public void andQuery() {
        withOtherHazelcastInstances(2, () -> {