use of org.infinispan.protostream.sampledomain.User in project infinispan by infinispan.
the class HotRodCacheQueries method createUser1.
public static User createUser1() {
User user = new User();
user.setId(1);
user.setName("Tom");
user.setSurname("Cat");
user.setGender(User.Gender.MALE);
user.setAccountIds(Collections.singleton(12));
Address address = new Address();
address.setStreet("Dark Alley");
address.setPostCode("1234");
user.setAddresses(Collections.singletonList(address));
return user;
}
use of org.infinispan.protostream.sampledomain.User in project infinispan by infinispan.
the class AbstractAuthorization method testBulkReadUsersCanQuery.
@Test
public void testBulkReadUsersCanQuery() {
org.infinispan.configuration.cache.ConfigurationBuilder builder = prepareIndexedCache();
for (TestUser user : EnumSet.of(TestUser.ADMIN, TestUser.DEPLOYER, TestUser.APPLICATION, TestUser.OBSERVER)) {
RemoteCache<Integer, User> userCache = getServerTest().hotrod().withClientConfiguration(clientConfigurationWithProtostreamMarshaller(user)).withServerConfiguration(builder).get();
User fromCache = userCache.get(1);
HotRodCacheQueries.assertUser1(fromCache);
QueryFactory qf = Search.getQueryFactory(userCache);
Query<User> query = qf.create("FROM sample_bank_account.User WHERE name = 'Tom'");
List<User> list = query.execute().list();
assertNotNull(list);
assertEquals(1, list.size());
assertEquals(User.class, list.get(0).getClass());
HotRodCacheQueries.assertUser1(list.get(0));
}
for (TestUser user : EnumSet.of(TestUser.ADMIN, TestUser.DEPLOYER, TestUser.APPLICATION, TestUser.OBSERVER)) {
RestCacheClient userCache = getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get().cache(getServerTest().getMethodName());
assertStatus(OK, userCache.query("FROM sample_bank_account.User WHERE name = 'Tom'"));
assertStatus(OK, userCache.searchStats());
assertStatus(OK, userCache.indexStats());
assertStatus(OK, userCache.queryStats());
}
}
use of org.infinispan.protostream.sampledomain.User in project protostream by infinispan.
the class UserMarshaller method readFrom.
@Override
public User readFrom(ProtoStreamReader reader) throws IOException {
int id = reader.readInt("id");
Set<Integer> accountIds = reader.readCollection("accountIds", new HashSet<>(), Integer.class);
String name = reader.readString("name");
String surname = reader.readString("surname");
String salutation = reader.readString("salutation");
List<Address> addresses = reader.readCollection("addresses", new ArrayList<>(), Address.class);
Integer age = reader.readInt("age");
User.Gender gender = reader.readEnum("gender", User.Gender.class);
String notes = reader.readString("notes");
Instant creationDate = reader.readInstant("creationDate");
Instant passwordExpirationDate = reader.readInstant("passwordExpirationDate");
User user = new User();
user.setId(id);
user.setAccountIds(accountIds);
user.setName(name);
user.setSurname(surname);
user.setSalutation(salutation);
user.setAge(age);
user.setGender(gender);
user.setAddresses(addresses);
user.setNotes(notes);
user.setCreationDate(creationDate);
user.setPasswordExpirationDate(passwordExpirationDate);
return user;
}
use of org.infinispan.protostream.sampledomain.User in project camel-spring-boot by apache.
the class InfinispanRemoteQueryConsumerIT method continuousQuery.
// *****************************
//
// *****************************
@Test
public void continuousQuery() throws Exception {
MockEndpoint continuousQueryBuilderNoMatch = getMockEndpoint("mock:continuousQueryNoMatch");
continuousQueryBuilderNoMatch.expectedMessageCount(0);
MockEndpoint continuousQueryBuilderAll = getMockEndpoint("mock:continuousQueryAll");
continuousQueryBuilderAll.expectedMessageCount(CQ_USERS.length * 2);
MockEndpoint continuousQuery = getMockEndpoint("mock:continuousQuery");
continuousQuery.expectedMessageCount(4);
for (int i = 0; i < 4; i++) {
continuousQuery.message(i).header(InfinispanConstants.KEY).isEqualTo(createKey(CQ_USERS[i % 2]));
continuousQuery.message(i).header(InfinispanConstants.CACHE_NAME).isEqualTo(getCache().getName());
if (i >= 2) {
continuousQuery.message(i).header(InfinispanConstants.EVENT_TYPE).isEqualTo(InfinispanConstants.CACHE_ENTRY_LEAVING);
continuousQuery.message(i).header(InfinispanConstants.EVENT_DATA).isNull();
} else {
continuousQuery.message(i).header(InfinispanConstants.EVENT_TYPE).isEqualTo(InfinispanConstants.CACHE_ENTRY_JOINING);
continuousQuery.message(i).header(InfinispanConstants.EVENT_DATA).isNotNull();
continuousQuery.message(i).header(InfinispanConstants.EVENT_DATA).isInstanceOf(User.class);
}
}
for (final User user : CQ_USERS) {
getCache().put(createKey(user), user);
}
assertEquals(CQ_USERS.length, getCache().size());
for (final User user : CQ_USERS) {
getCache().remove(createKey(user));
}
assertTrue(getCache().isEmpty());
continuousQuery.assertIsSatisfied();
continuousQueryBuilderNoMatch.assertIsSatisfied();
continuousQueryBuilderAll.assertIsSatisfied();
}
Aggregations