Search in sources :

Example 1 with DataChannelSyncStats

use of org.apache.cayenne.unit.di.DataChannelSyncStats in project cayenne by apache.

the class CayenneContextGraphDiffCompressorIT method testMultipleSimpleProperties.

@Test
public void testMultipleSimpleProperties() {
    ClientMtTable1 o1 = context.newObject(ClientMtTable1.class);
    o1.setGlobalAttribute1("v1");
    o1.setGlobalAttribute1("v2");
    DataChannelSyncStats stats = clientServerInterceptor.runWithSyncStatsCollection(new UnitTestClosure() {

        public void execute() {
            context.commitChanges();
        }
    });
    assertEquals(1, stats.nodePropertiesChanged);
    assertEquals(1, stats.nodesCreated);
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) DataChannelSyncStats(org.apache.cayenne.unit.di.DataChannelSyncStats) UnitTestClosure(org.apache.cayenne.unit.di.UnitTestClosure) Test(org.junit.Test)

Example 2 with DataChannelSyncStats

use of org.apache.cayenne.unit.di.DataChannelSyncStats in project cayenne by apache.

the class CayenneContextGraphDiffCompressorIT method testComplimentaryArcs.

@Test
public void testComplimentaryArcs() {
    ClientMtTable1 o1 = context.newObject(ClientMtTable1.class);
    ClientMtTable2 o2 = context.newObject(ClientMtTable2.class);
    o2.setTable1(o1);
    o2.setTable1(null);
    DataChannelSyncStats stats = clientServerInterceptor.runWithSyncStatsCollection(new UnitTestClosure() {

        public void execute() {
            context.commitChanges();
        }
    });
    assertEquals(0, stats.nodePropertiesChanged);
    assertEquals(2, stats.nodesCreated);
    assertEquals(0, stats.arcsCreated);
    assertEquals(0, stats.arcsDeleted);
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) ClientMtTable2(org.apache.cayenne.testdo.mt.ClientMtTable2) DataChannelSyncStats(org.apache.cayenne.unit.di.DataChannelSyncStats) UnitTestClosure(org.apache.cayenne.unit.di.UnitTestClosure) Test(org.junit.Test)

Example 3 with DataChannelSyncStats

use of org.apache.cayenne.unit.di.DataChannelSyncStats in project cayenne by apache.

the class ClientServerDataChannelInterceptor method runWithSyncStatsCollection.

public DataChannelSyncStats runWithSyncStatsCollection(UnitTestClosure closure) {
    ClientServerDataChannelDecorator channel = getChannelDecorator();
    DataChannelSyncStats stats = new DataChannelSyncStats();
    channel.setSyncStatsCounter(stats);
    try {
        closure.execute();
    } finally {
        channel.setSyncStatsCounter(null);
    }
    return stats;
}
Also used : DataChannelSyncStats(org.apache.cayenne.unit.di.DataChannelSyncStats)

Example 4 with DataChannelSyncStats

use of org.apache.cayenne.unit.di.DataChannelSyncStats in project cayenne by apache.

the class CayenneContextGraphDiffCompressorIT method testDelete.

@Test
public void testDelete() {
    ClientMtTable1 o1 = context.newObject(ClientMtTable1.class);
    o1.setGlobalAttribute1("v1");
    context.deleteObjects(o1);
    DataChannelSyncStats stats = clientServerInterceptor.runWithSyncStatsCollection(new UnitTestClosure() {

        public void execute() {
            context.commitChanges();
        }
    });
    assertEquals(0, stats.nodePropertiesChanged);
    assertEquals(0, stats.nodesCreated);
    assertEquals(0, stats.nodesRemoved);
}
Also used : ClientMtTable1(org.apache.cayenne.testdo.mt.ClientMtTable1) DataChannelSyncStats(org.apache.cayenne.unit.di.DataChannelSyncStats) UnitTestClosure(org.apache.cayenne.unit.di.UnitTestClosure) Test(org.junit.Test)

Aggregations

DataChannelSyncStats (org.apache.cayenne.unit.di.DataChannelSyncStats)4 ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)3 UnitTestClosure (org.apache.cayenne.unit.di.UnitTestClosure)3 Test (org.junit.Test)3 ClientMtTable2 (org.apache.cayenne.testdo.mt.ClientMtTable2)1