Search in sources :

Example 1 with Author

use of org.infinispan.query.dsl.embedded.testdomain.Author in project infinispan by infinispan.

the class EmbeddedQueryEngineTest method init.

@BeforeClass(alwaysRun = true)
protected void init() throws Exception {
    qe = new QueryEngine<>(cache(0).getAdvancedCache(), true);
    // create the test objects
    User user1 = new UserHS();
    user1.setId(1);
    user1.setName("John");
    user1.setSurname("Doe");
    user1.setGender(User.Gender.MALE);
    user1.setAge(22);
    user1.setAccountIds(new HashSet<>(Arrays.asList(1, 2)));
    user1.setNotes("Lorem ipsum dolor sit amet");
    Address address1 = new AddressHS();
    address1.setStreet("Main Street");
    address1.setPostCode("X1234");
    user1.setAddresses(Collections.singletonList(address1));
    User user2 = new UserHS();
    user2.setId(2);
    user2.setName("Spider");
    user2.setSurname("Man");
    user2.setGender(User.Gender.MALE);
    user2.setAge(44);
    user2.setAccountIds(Collections.singleton(3));
    Address address2 = new AddressHS();
    address2.setStreet("Old Street");
    address2.setPostCode("Y12");
    Address address3 = new AddressHS();
    address3.setStreet("Bond Street");
    address3.setPostCode("ZZ");
    user2.setAddresses(Arrays.asList(address2, address3));
    User user3 = new UserHS();
    user3.setId(3);
    user3.setName("Spider");
    user3.setSurname("Woman");
    user3.setGender(User.Gender.FEMALE);
    user3.setAccountIds(Collections.emptySet());
    Account account1 = new AccountHS();
    account1.setId(1);
    account1.setDescription("John Doe's first bank account");
    account1.setCreationDate(makeDate("2013-01-03"));
    Account account2 = new AccountHS();
    account2.setId(2);
    account2.setDescription("John Doe's second bank account");
    account2.setCreationDate(makeDate("2013-01-04"));
    Account account3 = new AccountHS();
    account3.setId(3);
    account3.setCreationDate(makeDate("2013-01-20"));
    Transaction transaction0 = new TransactionHS();
    transaction0.setId(0);
    transaction0.setDescription("Birthday present");
    transaction0.setAccountId(1);
    transaction0.setAmount(1800);
    transaction0.setDate(makeDate("2012-09-07"));
    transaction0.setDebit(false);
    transaction0.setValid(true);
    Transaction transaction1 = new TransactionHS();
    transaction1.setId(1);
    transaction1.setDescription("Feb. rent payment");
    transaction1.setAccountId(1);
    transaction1.setAmount(1500);
    transaction1.setDate(makeDate("2013-01-05"));
    transaction1.setDebit(true);
    transaction1.setValid(true);
    Transaction transaction2 = new TransactionHS();
    transaction2.setId(2);
    transaction2.setDescription("Starbucks");
    transaction2.setAccountId(1);
    transaction2.setAmount(23);
    transaction2.setDate(makeDate("2013-01-09"));
    transaction2.setDebit(true);
    transaction2.setValid(true);
    Transaction transaction3 = new TransactionHS();
    transaction3.setId(3);
    transaction3.setDescription("Hotel");
    transaction3.setAccountId(2);
    transaction3.setAmount(45);
    transaction3.setDate(makeDate("2013-02-27"));
    transaction3.setDebit(true);
    transaction3.setValid(true);
    Transaction transaction4 = new TransactionHS();
    transaction4.setId(4);
    transaction4.setDescription("Last january");
    transaction4.setAccountId(2);
    transaction4.setAmount(95);
    transaction4.setDate(makeDate("2013-01-31"));
    transaction4.setDebit(true);
    transaction4.setValid(true);
    Transaction transaction5 = new TransactionHS();
    transaction5.setId(5);
    transaction5.setDescription("Popcorn");
    transaction5.setAccountId(2);
    transaction5.setAmount(5);
    transaction5.setDate(makeDate("2013-01-01"));
    transaction5.setDebit(true);
    transaction5.setValid(true);
    // persist and index the test objects
    // we put all of them in the same cache for the sake of simplicity
    cache(0).put("user_" + user1.getId(), user1);
    cache(0).put("user_" + user2.getId(), user2);
    cache(0).put("user_" + user3.getId(), user3);
    cache(0).put("account_" + account1.getId(), account1);
    cache(0).put("account_" + account2.getId(), account2);
    cache(0).put("account_" + account3.getId(), account3);
    cache(0).put("transaction_" + transaction0.getId(), transaction0);
    cache(0).put("transaction_" + transaction1.getId(), transaction1);
    cache(0).put("transaction_" + transaction2.getId(), transaction2);
    cache(0).put("transaction_" + transaction3.getId(), transaction3);
    cache(0).put("transaction_" + transaction4.getId(), transaction4);
    cache(0).put("transaction_" + transaction5.getId(), transaction5);
    for (int i = 0; i < 50; i++) {
        Transaction transaction = new TransactionHS();
        transaction.setId(50 + i);
        transaction.setDescription("Expensive shoes " + i);
        transaction.setAccountId(2);
        transaction.setAmount(100 + i);
        transaction.setDate(makeDate("2013-08-20"));
        transaction.setDebit(true);
        transaction.setValid(true);
        cache(0).put("transaction_" + transaction.getId(), transaction);
    }
    // this value should be ignored gracefully
    cache(0).put("dummy", "a primitive value cannot be queried");
    cache(0).put("notIndexed1", new NotIndexed("testing 123"));
    cache(0).put("notIndexed2", new NotIndexed("xyz"));
    cache(0).put("entity1", new TheEntity("test value 1", new TheEntity.TheEmbeddedEntity("test embedded value 1")));
    cache(0).put("entity2", new TheEntity("test value 2", new TheEntity.TheEmbeddedEntity("test embedded value 2")));
    cache(0).put("book1", new Book("Java Performance: The Definitive Guide", "O'Reilly Media", new Author("Scott", "Oaks"), "Still, it turns out that every day, I think about GC performance, or the\n" + "performance of the JVM compiler, or how to get the best performance from Java Enterprise Edition APIs."));
    cache(0).put("book2", new Book("Functional Programming for Java Developers", "O'Reilly Media", new Author("Dean", "Wampler"), "Why should a Java developer learn about functional programming (FP)? After all, hasn’t\n" + "functional programming been safely hidden in academia for decades? Isn’t object-\n" + "oriented programming (OOP) all we really need?"));
    cache(0).put("book3", new Book("The Java ® Virtual Machine Specification Java SE 8 Edition", "Oracle", new Author("Tim", "Lindholm"), "The Java SE 8 Edition of The Java Virtual Machine Specification incorporates all the changes that have " + "been made to the Java Virtual Machine since the Java SE 7 Edition in 2011. In addition, numerous " + "corrections and clarifications have been made to align with popular implementations of the Java Virtual Machine."));
}
Also used : Account(org.infinispan.query.dsl.embedded.testdomain.Account) User(org.infinispan.query.dsl.embedded.testdomain.User) Address(org.infinispan.query.dsl.embedded.testdomain.Address) UserHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.UserHS) AddressHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.AddressHS) TheEntity(org.infinispan.query.dsl.embedded.impl.model.TheEntity) AccountHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS) Transaction(org.infinispan.query.dsl.embedded.testdomain.Transaction) Book(org.infinispan.query.dsl.embedded.testdomain.Book) Author(org.infinispan.query.dsl.embedded.testdomain.Author) TransactionHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS) NotIndexed(org.infinispan.query.dsl.embedded.testdomain.NotIndexed) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TheEntity (org.infinispan.query.dsl.embedded.impl.model.TheEntity)1 Account (org.infinispan.query.dsl.embedded.testdomain.Account)1 Address (org.infinispan.query.dsl.embedded.testdomain.Address)1 Author (org.infinispan.query.dsl.embedded.testdomain.Author)1 Book (org.infinispan.query.dsl.embedded.testdomain.Book)1 NotIndexed (org.infinispan.query.dsl.embedded.testdomain.NotIndexed)1 Transaction (org.infinispan.query.dsl.embedded.testdomain.Transaction)1 User (org.infinispan.query.dsl.embedded.testdomain.User)1 AccountHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS)1 AddressHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.AddressHS)1 TransactionHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS)1 UserHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.UserHS)1 BeforeClass (org.testng.annotations.BeforeClass)1