Search in sources :

Example 1 with LifecycleListener

use of org.apache.cayenne.LifecycleListener 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 LifecycleListener

use of org.apache.cayenne.LifecycleListener 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 3 with LifecycleListener

use of org.apache.cayenne.LifecycleListener 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)

Example 4 with LifecycleListener

use of org.apache.cayenne.LifecycleListener in project cayenne by apache.

the class LifecycleCallbackRegistryTest method addDefaultListener.

@Test
public void addDefaultListener() throws Exception {
    LifecycleListener listener = mock(LifecycleListener.class);
    registry.addDefaultListener(listener);
    for (LifecycleEvent event : LifecycleEvent.values()) {
        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)

Aggregations

LifecycleListener (org.apache.cayenne.LifecycleListener)4 LifecycleEvent (org.apache.cayenne.map.LifecycleEvent)4 Test (org.junit.Test)4