Search in sources :

Example 1 with ClassDescriptorFactory

use of org.apache.cayenne.reflect.ClassDescriptorFactory in project cayenne by apache.

the class EntityResolverClassDescriptorIT method testServerDescriptorFactory.

@Test
public void testServerDescriptorFactory() {
    EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
    resolver.getClassDescriptorMap().clearDescriptors();
    ClassDescriptor descriptor = mock(ClassDescriptor.class);
    ClassDescriptorFactory factory = mock(ClassDescriptorFactory.class);
    when(factory.getDescriptor("MtTable1")).thenReturn(descriptor);
    resolver.getClassDescriptorMap().addFactory(factory);
    try {
        ClassDescriptor resolved = resolver.getClassDescriptor("MtTable1");
        assertNotNull(resolved);
        resolved = ((LazyClassDescriptorDecorator) resolved).getDescriptor();
        assertSame(descriptor, resolved);
    } finally {
        resolver.getClassDescriptorMap().removeFactory(factory);
    }
}
Also used : ClassDescriptor(org.apache.cayenne.reflect.ClassDescriptor) ClassDescriptorFactory(org.apache.cayenne.reflect.ClassDescriptorFactory) Test(org.junit.Test)

Aggregations

ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)1 ClassDescriptorFactory (org.apache.cayenne.reflect.ClassDescriptorFactory)1 Test (org.junit.Test)1