Search in sources :

Example 16 with ArtGroup

use of org.apache.cayenne.testdo.testmap.ArtGroup in project cayenne by apache.

the class CDOReflexiveRelIT method testAddDeleteWithCommit.

@Test
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();
}
Also used : ArtGroup(org.apache.cayenne.testdo.testmap.ArtGroup) Test(org.junit.Test)

Example 17 with ArtGroup

use of org.apache.cayenne.testdo.testmap.ArtGroup in project cayenne by apache.

the class CDOReflexiveRelIT method testReplaceDeleteWithCommit.

@Test
public void testReplaceDeleteWithCommit() {
    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.commitChanges();
    context.deleteObjects(parentGroup1);
    context.deleteObjects(parentGroup2);
    context.commitChanges();
}
Also used : ArtGroup(org.apache.cayenne.testdo.testmap.ArtGroup) Test(org.junit.Test)

Example 18 with ArtGroup

use of org.apache.cayenne.testdo.testmap.ArtGroup in project cayenne by apache.

the class CDOReflexiveRelIT method testReplaceDeleteNoCommit.

@Test
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);
}
Also used : ArtGroup(org.apache.cayenne.testdo.testmap.ArtGroup) Test(org.junit.Test)

Example 19 with ArtGroup

use of org.apache.cayenne.testdo.testmap.ArtGroup in project cayenne by apache.

the class CDOReflexiveRelIT method testCommitReplaceCommit.

@Test
public void testCommitReplaceCommit() {
    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);
    context.commitChanges();
    childGroup1.setToParentGroup(parentGroup2);
    context.commitChanges();
}
Also used : ArtGroup(org.apache.cayenne.testdo.testmap.ArtGroup) Test(org.junit.Test)

Example 20 with ArtGroup

use of org.apache.cayenne.testdo.testmap.ArtGroup in project cayenne by apache.

the class CayenneDataObjectFlattenedRelIT method testAddRemoveFlattenedRelationship2.

@Test
public void testAddRemoveFlattenedRelationship2() throws Exception {
    create1Artist2ArtGroupDataSet();
    Artist a1 = Cayenne.objectForPK(context, Artist.class, 33001);
    SelectQuery q = new SelectQuery(ArtGroup.class);
    List<?> results = context.performQuery(q);
    assertEquals(2, results.size());
    ArtGroup g1 = (ArtGroup) results.get(0);
    ArtGroup g2 = (ArtGroup) results.get(1);
    a1.addToGroupArray(g1);
    a1.addToGroupArray(g2);
    // test that there is no delete query issued when a flattened join is first
    // added and then deleted AND there are some other changes (CAY-548)
    a1.removeFromGroupArray(g1);
    MockDataNode nodeWrapper = MockDataNode.interceptNode(runtime.getDataDomain(), runtime.getDataDomain().getDataNodes().iterator().next());
    try {
        context.commitChanges();
    } finally {
        nodeWrapper.stopInterceptNode();
    }
    assertEquals(1, nodeWrapper.getRunCount());
}
Also used : Artist(org.apache.cayenne.testdo.testmap.Artist) SelectQuery(org.apache.cayenne.query.SelectQuery) MockDataNode(org.apache.cayenne.access.MockDataNode) ArtGroup(org.apache.cayenne.testdo.testmap.ArtGroup) Test(org.junit.Test)

Aggregations

ArtGroup (org.apache.cayenne.testdo.testmap.ArtGroup)29 Test (org.junit.Test)29 Artist (org.apache.cayenne.testdo.testmap.Artist)16 SelectQuery (org.apache.cayenne.query.SelectQuery)9 UnitTestClosure (org.apache.cayenne.unit.di.UnitTestClosure)8 HashSet (java.util.HashSet)4 List (java.util.List)4 Set (java.util.Set)4 ValueHolder (org.apache.cayenne.ValueHolder)4 ObjectContext (org.apache.cayenne.ObjectContext)2 SQLTemplate (org.apache.cayenne.query.SQLTemplate)2 Painting (org.apache.cayenne.testdo.testmap.Painting)2 MockDataNode (org.apache.cayenne.access.MockDataNode)1 ObjEntity (org.apache.cayenne.map.ObjEntity)1 ObjRelationship (org.apache.cayenne.map.ObjRelationship)1