Package org.apache.cayenne.jpa.conf

Examples of org.apache.cayenne.jpa.conf.EntityMapLoaderContext


                .getCallbackMethods()
                .size());
    }

    public void testEntityListeners() {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        JpaEntityMap jpaMap = context.getEntityMap();

        JpaTable table = new JpaTable();
        table.setName("ET1");
       
        JpaEntity jpaEntity = new JpaEntity();
View Full Code Here


        assertEquals(1, cl1.getCallbackMap().getPreRemove().getCallbackMethods().size());
        assertEquals(0, cl1.getCallbackMap().getPostPersist().getCallbackMethods().size());
    }

    public void testDataMapDefaults() {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        JpaEntityMap jpaMap = context.getEntityMap();
        jpaMap.setPackageName("p1");
        jpaMap.setSchema("s1");

        // TODO: unsupported by DataMap
        // jpaMap.setCatalog("c1");
View Full Code Here

        assertEquals("p1", cayenneMap.getDefaultPackage());
        assertEquals("s1", cayenneMap.getDefaultSchema());
    }

    public void testLoadClassMapping() throws Exception {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);

        loader.loadClassMapping(MockCayenneEntity1.class);
        loader.loadClassMapping(MockCayenneEntity2.class);
        loader.loadClassMapping(MockCayenneTargetEntity1.class);
        loader.loadClassMapping(MockCayenneTargetEntity2.class);

        loader.loadClassMapping(MockCayenneEntityMap1.class);

        // apply defaults before conversion
        new EntityMapDefaultsProcessor().applyDefaults(context);

        assertFalse("Found conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DataMap dataMap = new DataMapConverter().toDataMap("n1", context);
        assertFalse("Found DataMap conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        new DataMapMappingAssertion().testDataMap(dataMap);
    }
View Full Code Here

        new DataMapMappingAssertion().testDataMap(dataMap);
    }

    public void testDataMapTypes() {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);

        loader.loadClassMapping(MockTypesEntity.class);

        // apply defaults before conversion
        new EntityMapDefaultsProcessor().applyDefaults(context);

        assertFalse("Found conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DataMap dataMap = new DataMapConverter().toDataMap("n1", context);
        assertFalse("Found DataMap conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DbEntity typesTable = dataMap.getDbEntity("MockTypesEntity");
        assertNotNull(typesTable);
View Full Code Here

        assertNotNull(byteArrayColumn);
        assertEquals(Types.BINARY, byteArrayColumn.getType());
    }

    public void testColumnOverrides() {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);

        loader.loadClassMapping(MockIdColumnEntity.class);

        // apply defaults before conversion
        new EntityMapDefaultsProcessor().applyDefaults(context);

        assertFalse("Found conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DataMap dataMap = new DataMapConverter().toDataMap("n1", context);
        assertFalse("Found DataMap conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DbEntity table = dataMap.getDbEntity("MockIdColumnEntity");
        assertNotNull(table);
View Full Code Here

        assertNotNull(pk);
        assertTrue(pk.isPrimaryKey());
    }

    public void testBasicOptionality() {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);

        loader.loadClassMapping(MockBasicEntity.class);

        // apply defaults before conversion
        new EntityMapDefaultsProcessor().applyDefaults(context);

        assertFalse("Found conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DataMap dataMap = new DataMapConverter().toDataMap("n1", context);
        assertFalse("Found DataMap conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DbEntity table = dataMap.getDbEntity("MockBasicEntity");
        assertNotNull(table);
View Full Code Here

        assertSame(dbr2, dbr1.getReverseRelationship());
        assertSame(dbr1, dbr2.getReverseRelationship());
    }

    private DataMap load(Class<?>... classes) {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        EntityMapAnnotationLoader loader = new EntityMapAnnotationLoader(context);

        for (Class<?> c : classes) {
            loader.loadClassMapping(c);
        }

        new EntityMapDefaultsProcessor().applyDefaults(context);
        assertFalse("Found conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());

        DataMap dataMap = new DataMapConverter().toDataMap("n1", context);
        assertFalse("Found DataMap conflicts: " + context.getConflicts(), context
                .getConflicts()
                .hasFailures());
        return dataMap;
    }
View Full Code Here

import org.apache.cayenne.map.ObjEntity;

public class DataMapConverterTest extends TestCase {

    public void testDefaultEntityListeners() {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        JpaEntityMap jpaMap = context.getEntityMap();

        JpaPersistenceUnitMetadata metadata = new JpaPersistenceUnitMetadata();
        jpaMap.setPersistenceUnitMetadata(metadata);

        JpaPersistenceUnitDefaults defaults = new JpaPersistenceUnitDefaults();
View Full Code Here

        assertEquals(1, cl1.getCallbackMap().getPreRemove().getCallbackMethods().size());
        assertEquals(0, cl1.getCallbackMap().getPostPersist().getCallbackMethods().size());
    }

    public void testEntityCallbackMethods() {
        EntityMapLoaderContext context = new EntityMapLoaderContext(
                new MockPersistenceUnitInfo());
        JpaEntityMap jpaMap = context.getEntityMap();

        JpaTable table = new JpaTable();
        table.setName("ET1");
       
        JpaEntity jpaEntity = new JpaEntity();
View Full Code Here

TOP

Related Classes of org.apache.cayenne.jpa.conf.EntityMapLoaderContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.