Search in sources :

Example 1 with Person

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()));
    }
}
Also used : Person(data.Person) InvocableMap(com.tangosol.util.InvocableMap) Map(java.util.Map) ObservableMap(com.tangosol.util.ObservableMap) ConcurrentMap(com.tangosol.util.ConcurrentMap) CacheMap(com.tangosol.net.cache.CacheMap) QueryMap(com.tangosol.util.QueryMap) Test(org.junit.jupiter.api.Test)

Example 2 with Person

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));
}
Also used : Subscriber(com.tangosol.net.topic.Subscriber) PhoneNumber(data.PhoneNumber) Person(data.Person) Test(org.junit.jupiter.api.Test)

Example 3 with Person

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);
}
Also used : InvalidObjectFieldException(exceptions.InvalidObjectFieldException) java.util(java.util) IncorrectIdException(exceptions.IncorrectIdException) Printer(io.Printer) LocalDateTime(java.time.LocalDateTime) ExecutionException(exceptions.ExecutionException) JsonFile(file.JsonFile) ExistingIdException(exceptions.ExistingIdException) IOException(java.io.IOException) Person(data.Person) Dragon(data.Dragon) ConsoleColor(io.ConsoleColor) Person(data.Person)

Example 4 with Person

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;
}
Also used : ExecutionException(exceptions.ExecutionException) Person(data.Person)

Example 5 with Person

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));
}
Also used : Coherence(com.tangosol.net.Coherence) PhoneNumber(data.PhoneNumber) Person(data.Person) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) Test(org.junit.jupiter.api.Test)

Aggregations

Person (data.Person)17 Test (org.junit.jupiter.api.Test)11 PhoneNumber (data.PhoneNumber)10 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)5 Serializer (com.tangosol.io.Serializer)2 BackingMapContext (com.tangosol.net.BackingMapContext)2 BackingMapBinaryEntry (com.tangosol.net.cache.BackingMapBinaryEntry)2 Subscriber (com.tangosol.net.topic.Subscriber)2 MapEvent (com.tangosol.util.MapEvent)2 ExecutionException (exceptions.ExecutionException)2 HashMap (java.util.HashMap)2 Person (org.apache.tapestry5.integration.app1.data.Person)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Coherence (com.tangosol.net.Coherence)1 CacheMap (com.tangosol.net.cache.CacheMap)1 ConcurrentMap (com.tangosol.util.ConcurrentMap)1 InvocableMap (com.tangosol.util.InvocableMap)1 MapIndex (com.tangosol.util.MapIndex)1 ObservableMap (com.tangosol.util.ObservableMap)1 QueryMap (com.tangosol.util.QueryMap)1