Package org.apache.cayenne.testdo.testmap

Examples of org.apache.cayenne.testdo.testmap.ArtGroup


     * Tests that deleting a source of a flattened relationship with CASCADE rule results
     * in deleting a join and a target.
     */
    public void testCascadeToManyFlattened() {
        // testing Artist.groupArray relationship
        ArtGroup aGroup = context.newObject(ArtGroup.class);
        aGroup.setName("Group Name");
        Artist anArtist = context.newObject(Artist.class);
        anArtist.setArtistName("A Name");
        anArtist.addToGroupArray(aGroup);
        assertTrue(anArtist.getGroupArray().contains(aGroup));

        context.commitChanges();

        SQLTemplate checkQuery = new SQLTemplate(
                Artist.class,
                "SELECT * FROM ARTIST_GROUP");
        checkQuery.setFetchingDataRows(true);
        List<?> joins1 = context.performQuery(checkQuery);
        assertEquals(1, joins1.size());

        context.deleteObjects(anArtist);

        assertEquals(PersistenceState.DELETED, aGroup.getPersistenceState());
        assertFalse(anArtist.getGroupArray().contains(aGroup));
        context.commitChanges();

        List<?> joins2 = context.performQuery(checkQuery);
        assertEquals(0, joins2.size());
View Full Code Here


     * Tests that deleting a source of a flattened relationship with NULLIFY rule results
     * in deleting a join together with the object deleted.
     */
    public void testNullifyToManyFlattened() {
        // testing ArtGroup.artistArray relationship
        ArtGroup aGroup = context.newObject(ArtGroup.class);
        aGroup.setName("Group Name");
        Artist anArtist = context.newObject(Artist.class);
        anArtist.setArtistName("A Name");
        aGroup.addToArtistArray(anArtist);

        context.commitChanges();

        // Preconditions
        assertTrue(aGroup.getArtistArray().contains(anArtist));
        assertTrue(anArtist.getGroupArray().contains(aGroup));

        SQLTemplate checkQuery = new SQLTemplate(
                Artist.class,
                "SELECT * FROM ARTIST_GROUP");
View Full Code Here

        assertEquals(0, joins2.size());
    }

    public void testNullifyToMany() {
        // ArtGroup childGroupsArray
        ArtGroup parentGroup = (ArtGroup) context.newObject("ArtGroup");
        parentGroup.setName("Parent");

        ArtGroup childGroup = (ArtGroup) context.newObject("ArtGroup");
        childGroup.setName("Child");
        parentGroup.addToChildGroupsArray(childGroup);

        // Preconditions - good to check to be sure
        assertEquals(parentGroup, childGroup.getToParentGroup());
        assertTrue(parentGroup.getChildGroupsArray().contains(childGroup));

        context.commitChanges();

        context.deleteObjects(parentGroup);

        // The things we are testing.
        assertNull(childGroup.getToParentGroup());

        // Although deleted, the property should be null (good cleanup policy)
        // assertFalse(parentGroup.getChildGroupsArray().contains(childGroup));
        context.commitChanges();
    }
View Full Code Here

        assertEquals(0, plist.size());
    }

    public void testReflexiveRelationshipInsertOrder1() {

        ArtGroup parentGroup = context.newObject(ArtGroup.class);
        parentGroup.setName("parent");

        ArtGroup childGroup1 = context.newObject(ArtGroup.class);
        childGroup1.setName("child1");
        childGroup1.setToParentGroup(parentGroup);
        context.commitChanges();
    }
View Full Code Here

        context.commitChanges();
    }

    public void testReflexiveRelationshipInsertOrder2() {

        ArtGroup childGroup1 = context.newObject(ArtGroup.class);
        childGroup1.setName("child1");

        ArtGroup parentGroup = context.newObject(ArtGroup.class);
        parentGroup.setName("parent");

        childGroup1.setToParentGroup(parentGroup);

        context.commitChanges();
    }
View Full Code Here

    }

    public void testReflexiveRelationshipInsertOrder3() {
        // multiple children, one created before parent, one after

        ArtGroup childGroup1 = context.newObject(ArtGroup.class);
        childGroup1.setName("child1");

        ArtGroup parentGroup = context.newObject(ArtGroup.class);
        parentGroup.setName("parent");

        childGroup1.setToParentGroup(parentGroup);

        ArtGroup childGroup2 = context.newObject(ArtGroup.class);
        childGroup2.setName("child2");
        childGroup2.setToParentGroup(parentGroup);

        context.commitChanges();
    }
View Full Code Here

    }

    public void testReflexiveRelationshipInsertOrder4() {
        // multiple children, one created before parent, one after

        ArtGroup childGroup1 = context.newObject(ArtGroup.class);
        childGroup1.setName("child1");

        ArtGroup parentGroup = context.newObject(ArtGroup.class);
        parentGroup.setName("parent");

        childGroup1.setToParentGroup(parentGroup);

        ArtGroup childGroup2 = context.newObject(ArtGroup.class);
        childGroup2.setName("subchild");
        childGroup2.setToParentGroup(childGroup1);

        context.commitChanges();
    }
View Full Code Here

    @Inject
    private ObjectContext context;

    public void testAddDeleteNoCommit() {
        ArtGroup parentGroup = context.newObject(ArtGroup.class);
        parentGroup.setName("parent");

        ArtGroup childGroup1 = context.newObject(ArtGroup.class);
        childGroup1.setName("child1");
        childGroup1.setToParentGroup(parentGroup);

        context.deleteObjects(parentGroup);
    }
View Full Code Here

        context.deleteObjects(parentGroup);
    }

    public void testAddDeleteWithCommit() {
        ArtGroup parentGroup = context.newObject(ArtGroup.class);
        parentGroup.setName("parent");

        ArtGroup childGroup1 = context.newObject(ArtGroup.class);
        childGroup1.setName("child1");
        childGroup1.setToParentGroup(parentGroup);
        context.commitChanges();

        context.deleteObjects(parentGroup);
        context.commitChanges();
    }
View Full Code Here

        context.deleteObjects(parentGroup);
        context.commitChanges();
    }

    public void testReplaceDeleteNoCommit() {
        ArtGroup parentGroup1 = context.newObject(ArtGroup.class);
        parentGroup1.setName("parent1");
        ArtGroup parentGroup2 = context.newObject(ArtGroup.class);
        parentGroup2.setName("parent2");

        ArtGroup childGroup1 = context.newObject(ArtGroup.class);
        childGroup1.setName("child1");
        childGroup1.setToParentGroup(parentGroup1);

        childGroup1.setToParentGroup(parentGroup2);

        context.deleteObjects(parentGroup1);
        context.deleteObjects(parentGroup2);
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.testdo.testmap.ArtGroup

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.