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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations