Search in sources :

Example 1 with Address

use of org.infinispan.protostream.sampledomain.Address in project infinispan by infinispan.

the class HotRodListenerWithDslFilter method testEventFilter.

@Test
public void testEventFilter() {
    RemoteCache<Integer, User> remoteCache = ClusteredIT.createQueryableCache(SERVER_TEST, true);
    User user1 = new User();
    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 Address();
    address1.setStreet("Main Street");
    address1.setPostCode("X1234");
    user1.setAddresses(Collections.singletonList(address1));
    User user2 = new User();
    user2.setId(2);
    user2.setName("Spider");
    user2.setSurname("Man");
    user2.setGender(User.Gender.MALE);
    user2.setAge(32);
    user2.setAccountIds(Collections.singleton(3));
    Address address2 = new Address();
    address2.setStreet("Old Street");
    address2.setPostCode("Y12");
    Address address3 = new Address();
    address3.setStreet("Bond Street");
    address3.setPostCode("ZZ");
    user2.setAddresses(Arrays.asList(address2, address3));
    User user3 = new User();
    user3.setId(3);
    user3.setName("Spider");
    user3.setSurname("Woman");
    user3.setGender(User.Gender.FEMALE);
    user3.setAge(31);
    user3.setAccountIds(Collections.emptySet());
    remoteCache.put(user1.getId(), user1);
    remoteCache.put(user2.getId(), user2);
    remoteCache.put(user3.getId(), user3);
    assertEquals(3, remoteCache.size());
    SerializationContext serCtx = MarshallerUtil.getSerializationContext(remoteCache.getRemoteCacheManager());
    QueryFactory qf = Search.getQueryFactory(remoteCache);
    Query<User> query = qf.<User>create("SELECT age FROM sample_bank_account.User WHERE age <= :ageParam").setParameter("ageParam", 32);
    ClientEntryListener listener = new ClientEntryListener(serCtx);
    ClientEvents.addClientQueryListener(remoteCache, listener, query);
    expectElementsInQueue(listener.createEvents, 3);
    user3.setAge(40);
    remoteCache.put(user1.getId(), user1);
    remoteCache.put(user2.getId(), user2);
    remoteCache.put(user3.getId(), user3);
    assertEquals(3, remoteCache.size());
    expectElementsInQueue(listener.modifyEvents, 2);
    remoteCache.removeClientListener(listener);
}
Also used : SerializationContext(org.infinispan.protostream.SerializationContext) QueryFactory(org.infinispan.query.dsl.QueryFactory) User(org.infinispan.protostream.sampledomain.User) Address(org.infinispan.protostream.sampledomain.Address) Test(org.junit.Test)

Example 2 with Address

use of org.infinispan.protostream.sampledomain.Address in project infinispan by infinispan.

the class ProtobufValueWrapperIndexingTest method createUser.

private User createUser(String name, String surname) {
    User user = new User();
    user.setId(1);
    user.setName(name);
    user.setSurname(surname);
    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;
}
Also used : User(org.infinispan.protostream.sampledomain.User) Address(org.infinispan.protostream.sampledomain.Address)

Example 3 with Address

use of org.infinispan.protostream.sampledomain.Address in project protostream by infinispan.

the class AddressMarshaller method readFrom.

@Override
public Address readFrom(ProtoStreamReader reader) throws IOException {
    String street = reader.readString("street");
    String postCode = reader.readString("postCode");
    int number = reader.readInt("number");
    Boolean isCommercial = reader.readBoolean("isCommercial");
    Address address = new Address();
    address.setStreet(street);
    address.setPostCode(postCode);
    address.setNumber(number);
    address.setCommercial(isCommercial);
    return address;
}
Also used : Address(org.infinispan.protostream.sampledomain.Address)

Example 4 with Address

use of org.infinispan.protostream.sampledomain.Address in project infinispan by infinispan.

the class HotRodCacheQueries method createUser2.

public static User createUser2() {
    User user = new User();
    user.setId(2);
    user.setName("Adrian");
    user.setSurname("Nistor");
    user.setGender(User.Gender.MALE);
    Address address = new Address();
    address.setStreet("Old Street");
    address.setPostCode("XYZ");
    user.setAddresses(Collections.singletonList(address));
    return user;
}
Also used : User(org.infinispan.protostream.sampledomain.User) Address(org.infinispan.protostream.sampledomain.Address)

Example 5 with Address

use of org.infinispan.protostream.sampledomain.Address 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;
}
Also used : User(org.infinispan.protostream.sampledomain.User) Address(org.infinispan.protostream.sampledomain.Address)

Aggregations

Address (org.infinispan.protostream.sampledomain.Address)6 User (org.infinispan.protostream.sampledomain.User)5 Instant (java.time.Instant)1 SerializationContext (org.infinispan.protostream.SerializationContext)1 QueryFactory (org.infinispan.query.dsl.QueryFactory)1 Test (org.junit.Test)1