Search in sources :

Example 1 with Account

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

the class EmbeddedAccountMarshaller method readFrom.

@Override
public AccountHS readFrom(ProtoStreamReader reader) throws IOException {
    int id = reader.readInt("id");
    String description = reader.readString("description");
    long creationDate = reader.readLong("creationDate");
    Limits limits = reader.readObject("limits", LimitsHS.class);
    Limits hardLimits = reader.readObject("hardLimits", LimitsHS.class);
    List<byte[]> blurb = reader.readCollection("blurb", new ArrayList<>(), byte[].class);
    Account.Currency[] currencies = reader.readArray("currencies", Account.Currency.class);
    AccountHS account = new AccountHS();
    account.setId(id);
    account.setDescription(description);
    account.setCreationDate(new Date(creationDate));
    account.setLimits(limits);
    account.setHardLimits(hardLimits);
    account.setBlurb(blurb);
    account.setCurrencies(currencies);
    return account;
}
Also used : Account(org.infinispan.query.dsl.embedded.testdomain.Account) Limits(org.infinispan.query.dsl.embedded.testdomain.Limits) AccountHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS) Date(java.util.Date)

Example 2 with Account

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

the class EmbeddedRemoteInteropQueryTest method testRemoteQueryForEmbeddedEntry.

public void testRemoteQueryForEmbeddedEntry() {
    AccountHS account = new AccountHS();
    account.setId(1);
    account.setDescription("test description");
    account.setCreationDate(new Date(42));
    cache.put(1, account);
    // get account back from remote cache via query and check its attributes
    QueryFactory qf = Search.getQueryFactory(remoteCache);
    Query<Account> query = qf.create("FROM sample_bank_account.Account WHERE description LIKE '%test%'");
    List<Account> list = query.execute().list();
    assertNotNull(list);
    assertEquals(1, list.size());
    assertAccount(list.get(0), AccountPB.class);
}
Also used : Account(org.infinispan.query.dsl.embedded.testdomain.Account) QueryFactory(org.infinispan.query.dsl.QueryFactory) AccountHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS) Date(java.util.Date)

Example 3 with Account

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

the class EmbeddedRemoteInteropQueryTest method testPutAndGetForEmbeddedEntry.

public void testPutAndGetForEmbeddedEntry() {
    AccountHS account = new AccountHS();
    account.setId(1);
    account.setDescription("test description");
    account.setCreationDate(new Date(42));
    cache.put(1, account);
    // try to get the object through the remote cache interface and check it's the same object we put
    assertEquals(1, remoteCache.keySet().size());
    Map.Entry<Integer, Account> entry = remoteCache.entrySet().iterator().next();
    assertAccount(entry.getValue(), AccountPB.class);
    // get the object through the embedded cache interface and check it's the same object we put
    Account fromEmbeddedCache = (Account) embeddedCache.get(1);
    assertAccount(fromEmbeddedCache, AccountHS.class);
}
Also used : Account(org.infinispan.query.dsl.embedded.testdomain.Account) AccountHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS) Map(java.util.Map) Date(java.util.Date)

Example 4 with Account

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

the class EmbeddedRemoteInteropQueryTest method testEqSentenceEmbedded.

public void testEqSentenceEmbedded() {
    AccountHS account = new AccountHS();
    account.setId(1);
    account.setDescription("John Doe's first bank account");
    account.setCreationDate(new Date(42));
    cache.put(1, account);
    QueryFactory qf = org.infinispan.query.Search.getQueryFactory(cache);
    Query<Account> q = qf.create("FROM " + AccountHS.class.getName() + " WHERE description = \"John Doe's first bank account\"");
    List<Account> list = q.execute().list();
    assertEquals(1, list.size());
    assertEquals(1, list.get(0).getId());
}
Also used : Account(org.infinispan.query.dsl.embedded.testdomain.Account) QueryFactory(org.infinispan.query.dsl.QueryFactory) AccountHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS) Date(java.util.Date)

Example 5 with Account

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

the class EmbeddedRemoteInteropQueryTest method testRemoteQuery.

public void testRemoteQuery() {
    Account account = createAccountPB(1);
    remoteCache.put(1, account);
    // get account back from remote cache via query and check its attributes
    QueryFactory qf = Search.getQueryFactory(remoteCache);
    Query<Account> query = qf.create("FROM sample_bank_account.Account WHERE description LIKE '%test%'");
    List<Account> list = query.execute().list();
    assertNotNull(list);
    assertEquals(1, list.size());
    assertAccount(list.get(0), AccountPB.class);
}
Also used : Account(org.infinispan.query.dsl.embedded.testdomain.Account) QueryFactory(org.infinispan.query.dsl.QueryFactory)

Aggregations

Account (org.infinispan.query.dsl.embedded.testdomain.Account)24 QueryFactory (org.infinispan.query.dsl.QueryFactory)17 EmbeddedQueryFactory (org.infinispan.query.core.impl.EmbeddedQueryFactory)9 Query (org.infinispan.query.dsl.Query)9 AccountHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS)7 Date (java.util.Date)6 AccountPB (org.infinispan.client.hotrod.query.testdomain.protobuf.AccountPB)4 User (org.infinispan.query.dsl.embedded.testdomain.User)3 Entry (java.util.Map.Entry)2 Address (org.infinispan.query.dsl.embedded.testdomain.Address)2 Limits (org.infinispan.query.dsl.embedded.testdomain.Limits)2 NotIndexed (org.infinispan.query.dsl.embedded.testdomain.NotIndexed)2 Transaction (org.infinispan.query.dsl.embedded.testdomain.Transaction)2 BeforeClass (org.testng.annotations.BeforeClass)2 Map (java.util.Map)1 Cache (org.infinispan.Cache)1 RemoteCache (org.infinispan.client.hotrod.RemoteCache)1 RemoteQueryFactory (org.infinispan.client.hotrod.impl.query.RemoteQueryFactory)1 AbstractKeyValueFilterConverter (org.infinispan.filter.AbstractKeyValueFilterConverter)1 Metadata (org.infinispan.metadata.Metadata)1