Search in sources :

Example 1 with LifecycleEvent

use of org.apache.cayenne.map.LifecycleEvent in project cayenne by apache.

the class LifecycleCallbackRegistryTest method addDefaultListenerSingleType.

@Test
public void addDefaultListenerSingleType() throws Exception {
    for (LifecycleEvent event : LifecycleEvent.values()) {
        assertEquals(0, registry.getHandler(event).defaultListenersSize());
        LifecycleListener listener = mock(LifecycleListener.class);
        registry.addDefaultListener(event, listener, nameToCamelCase(event.name()));
        assertEquals(1, registry.getHandler(event).defaultListenersSize());
        assertEquals(0, registry.getHandler(event).listenersSize());
    }
}
Also used : LifecycleEvent(org.apache.cayenne.map.LifecycleEvent) LifecycleListener(org.apache.cayenne.LifecycleListener) Test(org.junit.Test)

Example 2 with LifecycleEvent

use of org.apache.cayenne.map.LifecycleEvent in project cayenne by apache.

the class LifecycleCallbackRegistryTest method addAnnotatedListenerWithEntityClass.

@Test
public void addAnnotatedListenerWithEntityClass() {
    registry.addListener(new AnnotatedListenerWithEntity());
    for (LifecycleEvent event : LifecycleEvent.values()) {
        assertEquals(0, registry.getHandler(event).defaultListenersSize());
        assertEquals(1, registry.getHandler(event).listenersSize());
    }
}
Also used : LifecycleEvent(org.apache.cayenne.map.LifecycleEvent) Test(org.junit.Test)

Example 3 with LifecycleEvent

use of org.apache.cayenne.map.LifecycleEvent in project cayenne by apache.

the class LifecycleCallbackRegistryTest method createRegistry.

@Before
public void createRegistry() {
    EntityResolver entityResolver = mock(EntityResolver.class);
    registry = new LifecycleCallbackRegistry(entityResolver);
    for (LifecycleEvent event : LifecycleEvent.values()) {
        assertEquals(0, registry.getHandler(event).defaultListenersSize());
        assertEquals(0, registry.getHandler(event).listenersSize());
    }
}
Also used : LifecycleEvent(org.apache.cayenne.map.LifecycleEvent) EntityResolver(org.apache.cayenne.map.EntityResolver) Before(org.junit.Before)

Example 4 with LifecycleEvent

use of org.apache.cayenne.map.LifecycleEvent in project cayenne by apache.

the class LifecycleCallbackRegistryTest method addListenerWithEntityClass.

@Test
public void addListenerWithEntityClass() throws Exception {
    LifecycleListener listener = mock(LifecycleListener.class);
    registry.addListener(Object.class, listener);
    for (LifecycleEvent event : LifecycleEvent.values()) {
        assertEquals(1, registry.getHandler(event).listenersSize());
        assertEquals(0, registry.getHandler(event).defaultListenersSize());
    }
}
Also used : LifecycleEvent(org.apache.cayenne.map.LifecycleEvent) LifecycleListener(org.apache.cayenne.LifecycleListener) Test(org.junit.Test)

Example 5 with LifecycleEvent

use of org.apache.cayenne.map.LifecycleEvent in project cayenne by apache.

the class LifecycleCallbackRegistryTest method addListenerWithEntityClassSingleType.

@Test
public void addListenerWithEntityClassSingleType() throws Exception {
    for (LifecycleEvent event : LifecycleEvent.values()) {
        assertEquals(0, registry.getHandler(event).listenersSize());
        LifecycleListener listener = mock(LifecycleListener.class);
        registry.addListener(event, Object.class, listener, nameToCamelCase(event.name()));
        assertEquals(1, registry.getHandler(event).listenersSize());
        assertEquals(0, registry.getHandler(event).defaultListenersSize());
    }
}
Also used : LifecycleEvent(org.apache.cayenne.map.LifecycleEvent) LifecycleListener(org.apache.cayenne.LifecycleListener) Test(org.junit.Test)

Aggregations

LifecycleEvent (org.apache.cayenne.map.LifecycleEvent)7 Test (org.junit.Test)6 LifecycleListener (org.apache.cayenne.LifecycleListener)4 EntityResolver (org.apache.cayenne.map.EntityResolver)1 Before (org.junit.Before)1