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;
}
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);
}
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);
}
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());
}
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);
}
Aggregations