public void testEventFilter() throws Exception { Object[] filterFactoryParams = new Object[] {"string_key_1", "user_1"}; ClientEntryListener listener = new ClientEntryListener(); remoteCache.addClientListener(listener, filterFactoryParams, null); User user1 = new UserPB(); user1.setId(1); user1.setName("John"); user1.setSurname("Doe"); user1.setGender(User.Gender.MALE); user1.setAge(22); remoteCache.put("string_key_1", "string value 1"); remoteCache.put("string_key_2", "string value 2"); remoteCache.put("user_1", user1); assertEquals(3, remoteCache.keySet().size()); ClientCacheEntryCreatedEvent e = listener.createEvents.poll(5, TimeUnit.SECONDS); assertEquals("string_key_1", e.getKey()); e = listener.createEvents.poll(5, TimeUnit.SECONDS); assertEquals("user_1", e.getKey()); e = listener.createEvents.poll(5, TimeUnit.SECONDS); assertNull("No more elements expected in queue!", e); }
private User createUser() { User user = new UserPB(); user.setId(1); user.setName("Tom"); user.setSurname("Cat"); user.setGender(User.Gender.MALE); user.setAccountIds(Collections.singleton(12)); Address address = new AddressPB(); address.setStreet("Dark Alley"); address.setPostCode("1234"); user.setAddresses(Collections.singletonList(address)); return user; }
public void testEventFilter() throws Exception { User user1 = new UserPB(); user1.setId(1); user1.setName("John"); user1.setSurname("Doe"); user1.setGender(User.Gender.MALE); user1.setAge(22); NoopEventListener listener = new NoopEventListener(); remoteCache.addClientListener(listener); expectElementsInQueue(listener.createEvents, 0); remoteCache.put("user_" + user1.getId(), user1); assertEquals(1, remoteCache.size()); expectElementsInQueue(listener.createEvents, 1); remoteCache.removeClientListener(listener); }