Search in sources :

Example 11 with ObjectChange

use of org.apache.cayenne.commitlog.model.ObjectChange in project cayenne by apache.

the class CommitLogFilter_ListenerInducedChangesIT method sortedChanges.

private List<ObjectChange> sortedChanges(InvocationOnMock invocation) {
    assertSame(context, invocation.getArguments()[0]);
    ChangeMap changes = (ChangeMap) invocation.getArguments()[1];
    List<ObjectChange> sortedChanges = new ArrayList<>(changes.getUniqueChanges());
    Collections.sort(sortedChanges, new Comparator<ObjectChange>() {

        public int compare(ObjectChange o1, ObjectChange o2) {
            return o1.getPostCommitId().getEntityName().compareTo(o2.getPostCommitId().getEntityName());
        }
    });
    return sortedChanges;
}
Also used : ChangeMap(org.apache.cayenne.commitlog.model.ChangeMap) ObjectChange(org.apache.cayenne.commitlog.model.ObjectChange) ArrayList(java.util.ArrayList)

Aggregations

ChangeMap (org.apache.cayenne.commitlog.model.ChangeMap)11 ObjectChange (org.apache.cayenne.commitlog.model.ObjectChange)11 ObjectContext (org.apache.cayenne.ObjectContext)10 Test (org.junit.Test)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 ObjectId (org.apache.cayenne.ObjectId)9 Auditable1 (org.apache.cayenne.commitlog.db.Auditable1)6 Auditable2 (org.apache.cayenne.commitlog.db.Auditable2)3 AuditableChild1 (org.apache.cayenne.commitlog.db.AuditableChild1)3 ToManyRelationshipChange (org.apache.cayenne.commitlog.model.ToManyRelationshipChange)3 AttributeChange (org.apache.cayenne.commitlog.model.AttributeChange)2 ArrayList (java.util.ArrayList)1 E3 (org.apache.cayenne.commitlog.db.E3)1 E4 (org.apache.cayenne.commitlog.db.E4)1 ToOneRelationshipChange (org.apache.cayenne.commitlog.model.ToOneRelationshipChange)1