use of data.Person in project coherence-spring by coherence-community.
the class CoherenceNamedCacheConfigurationViewTest method shouldInjectContinuousQueryCacheWithTransformer.
@Test
void shouldInjectContinuousQueryCacheWithTransformer() {
WithTransformersBean bean = this.ctx.getBean(WithTransformersBean.class);
NamedCache<String, Person> cache = bean.getNamedCache();
ContinuousQueryCache<String, Person, String> names = bean.getNames();
// populate the underlying cache
populate(cache);
assertThat(names.size(), is(cache.size()));
for (Map.Entry<String, Person> entry : cache.entrySet()) {
final String key = entry.getKey();
final Person person = entry.getValue();
MatcherAssert.assertThat(names.get(key), CoreMatchers.is(person.getFirstName()));
}
}
use of data.Person in project coherence-spring by coherence-community.
the class NamedTopicConfigurationTest method shouldInjectPublisher.
@Test
public void shouldInjectPublisher() throws Exception {
NamedTopicPublisherFieldsBean publisherBean = this.ctx.getBean(NamedTopicPublisherFieldsBean.class);
NamedTopicSubscriberFieldsBean subscriberBean = this.ctx.getBean(NamedTopicSubscriberFieldsBean.class);
Publisher<Integer> numbersPublisher = publisherBean.getIntegers();
assertThat(numbersPublisher, is(notNullValue()));
Publisher<Person> peoplePublisher = publisherBean.getPeople();
assertThat(peoplePublisher, is(notNullValue()));
Subscriber<Integer> numbersSubscriber = subscriberBean.getIntegers();
assertThat(numbersSubscriber, is(notNullValue()));
Subscriber<Person> peopleSubscriber = subscriberBean.getPeople();
assertThat(peopleSubscriber, is(notNullValue()));
Subscriber<String> peopleFirstNamesSubscriber = subscriberBean.getPeopleFirstNames();
assertThat(peopleFirstNamesSubscriber, is(notNullValue()));
Subscriber<Person> peopleFilteredSubscriber = subscriberBean.getPeopleFiltered();
assertThat(peopleFilteredSubscriber, is(notNullValue()));
CompletableFuture<Subscriber.Element<Integer>> receiveNumber = numbersSubscriber.receive();
numbersPublisher.publish(19).join();
Subscriber.Element<Integer> element = receiveNumber.get(1, TimeUnit.MINUTES);
assertThat(element.getValue(), is(19));
Person homer = new Person("Homer", "Simpson", LocalDate.now(), new PhoneNumber(1, "555-123-9999"));
Person bart = new Person("Bart", "Simpson", LocalDate.now(), new PhoneNumber(1, "555-123-9999"));
CompletableFuture<Subscriber.Element<Person>> receivePerson = peopleSubscriber.receive();
CompletableFuture<Subscriber.Element<String>> receiveName = peopleFirstNamesSubscriber.receive();
CompletableFuture<Subscriber.Element<Person>> receiveFiltered = peopleFilteredSubscriber.receive();
peoplePublisher.publish(homer).join();
Subscriber.Element<Person> personElement = receivePerson.get(1, TimeUnit.MINUTES);
Subscriber.Element<String> nameElement = receiveName.get(1, TimeUnit.MINUTES);
assertThat(personElement.getValue(), is(homer));
assertThat(nameElement.getValue(), is(homer.getFirstName()));
assertThat(receiveFiltered.isDone(), is(false));
peoplePublisher.publish(bart).join();
personElement = receiveFiltered.get(1, TimeUnit.MINUTES);
assertThat(personElement.getValue(), is(bart));
}
use of data.Person in project Lab5 by Arslanka.
the class Collection method countGreaterThanKiller.
public void countGreaterThanKiller(Object personObj) {
Person killer = (Person) personObj;
long cnt = dragonHashSet.stream().filter(d -> d.getKiller().compareTo(killer) > 0).count();
printer.println("Collection elements that have a killer field greater than the specified one – " + cnt, HELP);
}
use of data.Person in project Lab5 by Arslanka.
the class CountGreaterThanKillerCommand method execute.
@Override
public boolean execute(Object... args) {
try {
Person person = (Person) args[0];
collection.countGreaterThanKiller(person);
printer.println(SEPARATOR, ERROR);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ExecutionException("You have not entered an item to add to the collection.");
}
return true;
}
use of data.Person in project micronaut-coherence by micronaut-projects.
the class InterceptorsTest method testEventInterceptorMethods.
@Test
void testEventInterceptorMethods() {
Coherence coherence = Coherence.getInstance();
CompletableFuture<Void> closeFuture = coherence.whenClosed();
// Ensure that Coherence has started before stating the test
coherence.whenStarted().join();
NamedCache<String, Person> people = session.getCache("people");
people.put("homer", new Person("Homer", "Simpson", LocalDate.now(), new PhoneNumber(1, "555-123-9999")));
people.put("marge", new Person("Marge", "Simpson", LocalDate.now(), new PhoneNumber(1, "555-123-9999")));
people.put("bart", new Person("Bart", "Simpson", LocalDate.now(), new PhoneNumber(1, "555-123-9999")));
people.put("lisa", new Person("Lisa", "Simpson", LocalDate.now(), new PhoneNumber(1, "555-123-9999")));
people.put("maggie", new Person("Maggie", "Simpson", LocalDate.now(), new PhoneNumber(1, "555-123-9999")));
people.invokeAll(new Uppercase());
people.clear();
people.truncate();
people.destroy();
context.close();
// ensure that Coherence is closed so that we should have the Stopped event
closeFuture.join();
observers.events.forEach((anEnum, integer) -> System.out.println(anEnum.getClass().getName() + "->" + anEnum + " count=" + integer));
Eventually.assertDeferred(() -> observers.events, hasEntry(LifecycleEvent.Type.ACTIVATING, 6));
Eventually.assertDeferred(() -> observers.events, hasEntry(LifecycleEvent.Type.ACTIVATED, 6));
Eventually.assertDeferred(() -> observers.events, hasEntry(LifecycleEvent.Type.DISPOSING, 6));
Eventually.assertDeferred(() -> observers.events, hasEntry(CacheLifecycleEvent.Type.CREATED, 3));
Eventually.assertDeferred(() -> observers.events, hasEntry(CacheLifecycleEvent.Type.DESTROYED, 3));
Eventually.assertDeferred(() -> observers.events, hasEntry(CacheLifecycleEvent.Type.TRUNCATED, 2));
Eventually.assertDeferred(() -> observers.events, hasEntry(TransferEvent.Type.ASSIGNED, 257));
Eventually.assertDeferred(() -> observers.events, hasEntry(TransactionEvent.Type.COMMITTING, 14));
Eventually.assertDeferred(() -> observers.events, hasEntry(TransactionEvent.Type.COMMITTED, 14));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryProcessorEvent.Type.EXECUTING, 1));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryProcessorEvent.Type.EXECUTED, 1));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryEvent.Type.INSERTING, 10));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryEvent.Type.INSERTED, 15));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryEvent.Type.UPDATING, 10));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryEvent.Type.UPDATED, 15));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryEvent.Type.REMOVING, 10));
Eventually.assertDeferred(() -> observers.events, hasEntry(EntryEvent.Type.REMOVED, 15));
Eventually.assertDeferred(() -> observers.events, hasEntry(CoherenceLifecycleEvent.Type.STARTING, 2));
Eventually.assertDeferred(() -> observers.events, hasEntry(CoherenceLifecycleEvent.Type.STARTED, 2));
Eventually.assertDeferred(() -> observers.events, hasEntry(CoherenceLifecycleEvent.Type.STOPPING, 2));
Eventually.assertDeferred(() -> observers.events, hasEntry(CoherenceLifecycleEvent.Type.STOPPED, 2));
Eventually.assertDeferred(() -> observers.events, hasEntry(SessionLifecycleEvent.Type.STARTING, 6));
Eventually.assertDeferred(() -> observers.events, hasEntry(SessionLifecycleEvent.Type.STARTED, 6));
Eventually.assertDeferred(() -> observers.events, hasEntry(SessionLifecycleEvent.Type.STOPPING, 6));
Eventually.assertDeferred(() -> observers.events, hasEntry(SessionLifecycleEvent.Type.STOPPED, 6));
}
Aggregations