use of org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS 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.hsearch.AccountHS 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.hsearch.AccountHS 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.hsearch.AccountHS 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.hsearch.AccountHS in project infinispan by infinispan.
the class BaseMultiServerRemoteIteratorTest method testFilterBySegment.
@Test
public void testFilterBySegment() {
RemoteCache<Integer, AccountHS> cache = clients.get(0).getCache();
populateCache(CACHE_SIZE, this::newAccount, cache);
CacheTopologyInfo cacheTopologyInfo = cache.getCacheTopologyInfo();
// Request all segments from one node
Set<Integer> filterBySegments = cacheTopologyInfo.getSegmentsPerServer().values().iterator().next();
Set<Entry<Object, Object>> entries = new HashSet<>();
try (CloseableIterator<Entry<Object, Object>> iterator = cache.retrieveEntries(null, filterBySegments, 10)) {
while (iterator.hasNext()) {
entries.add(iterator.next());
}
}
Marshaller marshaller = clients.get(0).getMarshaller();
KeyPartitioner keyPartitioner = TestingUtil.extractComponent(cache(0), KeyPartitioner.class);
assertKeysInSegment(entries, filterBySegments, marshaller, keyPartitioner::getSegment);
}
Aggregations