Package org.apache.isis.runtimes.dflt.objectstores.sql.testsystem

Examples of org.apache.isis.runtimes.dflt.objectstores.sql.testsystem.SqlDataClassFactory


        SqlIntegrationTestSingleton.drop("ISIS_POLYSUBCLASSTHREE");
        SqlIntegrationTestSingleton.drop("ISIS_POLYINTERFACEIMPLA");
        SqlIntegrationTestSingleton.drop("ISIS_POLYINTERFACEIMPLB");
        SqlIntegrationTestSingleton.drop("ISIS_POLYSELFREFCLASS");

        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        final PolyTestClass polyTestClass = factory.newPolyTestClass();
        polyTestClass.setString("polyTestClassString");

        // {{ Setup self-referencing collection
        final PolySelfRefClass polySelfRefClassParent = factory.newPolySelfRefClass();
        polySelfRefClassParent.setString("Parent");

        final PolySelfRefClass polySelfRefClassChild1 = factory.newPolySelfRefClass();
        polySelfRefClassChild1.setString(CHILD_1);
        polySelfRefClassParent.addToPolySelfRefClasses(polySelfRefClassChild1);

        final PolySelfRefClass polySelfRefClassChild2 = factory.newPolySelfRefClass();
        polySelfRefClassChild2.setString("Child 2");
        polySelfRefClassParent.addToPolySelfRefClasses(polySelfRefClassChild2);
        factory.save(polySelfRefClassChild2);

        final PolySelfRefClass polySelfRefClassChild3 = factory.newPolySelfRefClass();
        polySelfRefClassChild3.setString("Child 1 of Child 1");
        polySelfRefClassChild1.addToPolySelfRefClasses(polySelfRefClassChild3);

        factory.save(polySelfRefClassChild3);
        factory.save(polySelfRefClassChild1);

        factory.save(polySelfRefClassParent);
        polyTestClass.setPolySelfRefClass(polySelfRefClassParent);
        // }}

        // polyTestClass.setPolyTestInterface(polyTestClass);

        polyIntImpA = factory.newPolyInterfaceImplA();
        polyIntImpA.setString(IMPL_A_STRING);
        polyIntImpA.setSpecial("special");
        factory.save(polyIntImpA);

        polyTestClass.setPolyInterfaceType(polyIntImpA);
        polyTestClass.getPolyInterfaces().add(polyIntImpA);

        // setup the polyTestClass
        final PolySubClassOne polySubClassOne = factory.newPolySubClassOne();
        polySubClassOne.setStringBase("PolySubClassOne 1");
        polySubClassOne.setStringClassOne("Class 1");

        final PolySubClassTwo polySubClassTwo = factory.newPolySubClassTwo();
        polySubClassTwo.setStringBase("PolySubClassTwo 1");
        polySubClassTwo.setStringClassTwo("Class 2");

        final PolySubClassThree polySubClassThree = factory.newPolySubClassThree();
        polySubClassThree.setStringBase("PolySubClassThree 1");
        polySubClassThree.setStringClassThree("Another String");
        polySubClassThree.setStringClassTwo("Class 3");

        polyTestClass.getPolyBaseClasses().add(polySubClassOne);
        polyTestClass.getPolyBaseClasses().add(polySubClassTwo);
        polyTestClass.getPolyBaseClasses().add(polySubClassThree);

        factory.save(polySubClassOne);
        factory.save(polySubClassTwo);
        factory.save(polySubClassThree);

        // store it and step the state engine
        factory.save(polyTestClass);

        // For in-memory only!
        if (getProperties().getProperty("isis.persistor") == "in-memory") {
            getSingletonInstance().setState(1);
        }
View Full Code Here


    }

    // testLoad() Must be the first test defined and run
    public void testLoad() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        final List<PolyTestClass> dataClasses = factory.allPolyTestClasses();
        assertEquals(1, dataClasses.size());
        final PolyTestClass polyTestClass = dataClasses.get(0);
        SqlIntegrationTestSingleton.setStaticPolyTestClass(polyTestClass);

        // Must set state to 1 to prevent re-initialisation
View Full Code Here

        assertEquals("Class 3", polySubClassThree.getStringClassTwo());
        assertEquals("Another String", polySubClassThree.getStringClassThree());
    }

    public void testInterfaceLoad() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        final PolyTestClass polyTestClass = SqlIntegrationTestSingleton.getStaticPolyTestClass();

        final PolyInterface loaded = polyTestClass.getPolyInterfaceType();
        factory.resolve(loaded);
        assertEquals(polyIntImpA.getString(), loaded.getString());
    }
View Full Code Here

        }
        assertNotNull(polySelfRefChild1);

        assertEquals(CHILD_1, polySelfRefChild1.title());

        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        List<PolySelfRefClass> list2 = polySelfRefChild1.getPolySelfRefClasses();
        factory.resolve(polySelfRefChild1);
        list2 = polySelfRefChild1.getPolySelfRefClasses();
        assertEquals(1, list2.size());
    }
View Full Code Here

        assertEquals(polyIntImpA.getString(), loaded.getString());
    }

    public void testInterfaceEditSave() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        polyIntImpB = factory.newPolyInterfaceImplB();
        polyIntImpB.setString(IMPL_B_STRING);
        polyIntImpB.setSpecial("special");
        polyIntImpB.setInteger(1);

        factory.save(polyIntImpB);

        final PolyTestClass polyTestClass = SqlIntegrationTestSingleton.getStaticPolyTestClass();
        polyTestClass.setPolyInterfaceType(polyIntImpB);

        getSingletonInstance().setState(0); // ready for testInterfaceEditSave
View Full Code Here

        final PolyInterface loaded = polyTestClass.getPolyInterfaceType();
        assertEquals(polyIntImpB.getString(), loaded.getString());
    }

    public void testAllInterfacesInstancesLoaded() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        final List<PolyInterface> list = factory.allPolyInterfaces();
        assertEquals(2, list.size());
    }
View Full Code Here

        final List<PolyInterface> list = factory.allPolyInterfaces();
        assertEquals(2, list.size());
    }

    public void testInterfacesLoadedByQuery() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        // PolyInterface query = polyIntImpA;

        final PolyInterfaceEx query = new PolyInterfaceEx();
        query.setString(IMPL_A_STRING);

        final List<PolyInterface> list = factory.queryPolyInterfaces(query);
        assertEquals(1, list.size());
    }
View Full Code Here

        final List<PolyInterface> list = factory.queryPolyInterfaces(query);
        assertEquals(1, list.size());
    }

    public void testInterfacesLoadedByQuerySpecial() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();

        final PolyInterfaceEx query = new PolyInterfaceEx();

        final List<PolyInterface> list = factory.queryPolyInterfaces(query);
        assertEquals(2, list.size());
    }
View Full Code Here

        final List<PolyInterface> list = factory.queryPolyInterfaces(query);
        assertEquals(2, list.size());
    }

    public void testFindByMatchPartialEntity() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        final EmptyInterface match = new EmptyInterfaceEx();
        final List<EmptyInterface> matches = factory.allEmptyInterfacesThatMatch(match);
        assertEquals(1, matches.size());

        final EmptyInterface emptyInterface = matches.get(0);
        final PolyInterfaceImplB imp = (PolyInterfaceImplB) emptyInterface;
        assertEquals(IMPL_B_STRING, imp.getString());
View Full Code Here

        final PolyInterfaceImplB imp = (PolyInterfaceImplB) emptyInterface;
        assertEquals(IMPL_B_STRING, imp.getString());
    }

    public void testCannotFindByMatchWithWrongValue() {
        final SqlDataClassFactory factory = SqlIntegrationTestSingleton.getSqlDataClassFactory();
        final PolyInterfaceImplB match = new PolyInterfaceImplB();
        match.setInteger(0);
        final List<EmptyInterface> matches = factory.allEmptyInterfacesThatMatch(match);
        assertEquals(0, matches.size());
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.runtimes.dflt.objectstores.sql.testsystem.SqlDataClassFactory

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.