use of data.PhoneNumber 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.PhoneNumber 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));
}
use of data.PhoneNumber in project micronaut-coherence by micronaut-projects.
the class MapListenerTest method testMapEvents.
@Test
void testMapEvents() {
NamedCache<String, Person> people = session.getCache("people");
// Wait for the listener registration as it is async
Eventually.assertDeferred(() -> EventsHelper.getListenerCount(people), is(greaterThanOrEqualTo(4)));
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.invoke("homer", new Uppercase());
people.invoke("bart", new Uppercase());
people.remove("bart");
people.remove("marge");
people.remove("lisa");
people.remove("maggie");
Eventually.assertDeferred(() -> listener.getEvents(MapEvent.ENTRY_INSERTED), is(5));
Eventually.assertDeferred(() -> listener.getEvents(MapEvent.ENTRY_UPDATED), is(2));
Eventually.assertDeferred(() -> listener.getEvents(MapEvent.ENTRY_DELETED), is(4));
// There should be an insert and an update for Bart.
// The delete for Bart does not match the filter because the lastName
// had been changed to uppercase.
List<MapEvent<String, Person>> filteredEvents = listener.getFilteredEvents();
Eventually.assertDeferred(filteredEvents::size, is(2));
MapEvent<String, Person> eventOne = filteredEvents.get(0);
MapEvent<String, Person> eventTwo = filteredEvents.get(1);
assertThat(eventOne.getId(), is(MapEvent.ENTRY_INSERTED));
assertThat(eventOne.getKey(), is("bart"));
assertThat(eventTwo.getId(), is(MapEvent.ENTRY_UPDATED));
assertThat(eventTwo.getKey(), is("bart"));
assertThat(eventTwo.getNewValue().getLastName(), is("SIMPSON"));
// Transformed events should just be inserts with the person's firstName as the new value
List<MapEvent<String, String>> transformedWithExtractorEvents = listener.getTransformedWithExtractorEvents();
Eventually.assertDeferred(transformedWithExtractorEvents::size, is(5));
assertThat(transformedWithExtractorEvents.get(0).getNewValue(), is("Homer"));
assertThat(transformedWithExtractorEvents.get(1).getNewValue(), is("Marge"));
assertThat(transformedWithExtractorEvents.get(2).getNewValue(), is("Bart"));
assertThat(transformedWithExtractorEvents.get(3).getNewValue(), is("Lisa"));
assertThat(transformedWithExtractorEvents.get(4).getNewValue(), is("Maggie"));
// Transformed events should just be inserts with the person's firstName in uppercase as the new value
List<MapEvent<String, String>> transformedEvents = listener.getTransformedEvents();
Eventually.assertDeferred(transformedEvents::size, is(5));
assertThat(transformedEvents.get(0).getNewValue(), is("HOMER"));
assertThat(transformedEvents.get(1).getNewValue(), is("MARGE"));
assertThat(transformedEvents.get(2).getNewValue(), is("BART"));
assertThat(transformedEvents.get(3).getNewValue(), is("LISA"));
assertThat(transformedEvents.get(4).getNewValue(), is("MAGGIE"));
}
use of data.PhoneNumber in project micronaut-coherence by micronaut-projects.
the class ExtractorFactoriesTest method setup.
@BeforeEach
void setup() {
phoneNumber = new PhoneNumber(44, "04242424242");
person = new Person("Arthur", "Dent", LocalDate.of(1978, 3, 8), phoneNumber);
binaryKey = ExternalizableHelper.toBinary("AD", pofContext);
binaryPerson = ExternalizableHelper.toBinary(person, pofContext);
BackingMapContext ctx = mock(BackingMapContext.class);
Map<ValueExtractor, MapIndex> index = new HashMap<>();
when(ctx.getIndexMap()).thenReturn(index);
entry = new BackingMapBinaryEntry(binaryKey, binaryPerson, binaryPerson, null) {
@Override
public Object getKey() {
return "AD";
}
@Override
public Object getValue() {
return person;
}
@Override
public BackingMapContext getBackingMapContext() {
return ctx;
}
@Override
public Serializer getSerializer() {
return pofContext;
}
};
}
use of data.PhoneNumber in project coherence-spring by coherence-community.
the class CoherenceNamedCacheConfigurationViewTest method populate.
private void populate(NamedCache<String, Person> cache) {
for (int i = 0; i < 100; i++) {
String lastName = (i % 2 == 0) ? "foo" : "bar";
Person bean = new Person(String.valueOf(i), lastName, LocalDate.now(), new PhoneNumber(44, "12345" + i));
cache.put(lastName + "-" + i, bean);
}
}
Aggregations