use of org.apache.cayenne.commitlog.db.Auditable4 in project cayenne by apache.
the class CommitLogFilter_FilteredIT method testPostCommit_IgnoreToOne.
@Test
public void testPostCommit_IgnoreToOne() throws SQLException {
auditable3.insert(1, "31", "32");
auditable3.insert(2, "33", "34");
auditable4.insert(11, "41", "41", 1);
final Auditable3 a32 = SelectById.query(Auditable3.class, 2).selectOne(context);
final Auditable4 a4 = SelectById.query(Auditable4.class, 11).selectOne(context);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
assertSame(context, invocation.getArguments()[0]);
ChangeMap changes = (ChangeMap) invocation.getArguments()[1];
assertNull(changes.getChanges().get(new ObjectId("Auditable4", Auditable4.ID_PK_COLUMN, 11)));
return null;
}
}).when(mockListener).onPostCommit(any(ObjectContext.class), any(ChangeMap.class));
a4.setAuditable3(a32);
context.commitChanges();
verify(mockListener).onPostCommit(any(ObjectContext.class), any(ChangeMap.class));
}
use of org.apache.cayenne.commitlog.db.Auditable4 in project cayenne by apache.
the class CommitLogFilter_FilteredIT method testPostCommit_IgnoreToMany.
@Test
public void testPostCommit_IgnoreToMany() throws SQLException {
auditable3.insert(1, "31", "32");
auditable4.insert(11, "41", "42", 1);
auditable4.insert(12, "43", "44", 1);
final Auditable3 a3 = SelectById.query(Auditable3.class, 1).selectOne(context);
final Auditable4 a41 = SelectById.query(Auditable4.class, 11).selectOne(context);
final Auditable4 a42 = SelectById.query(Auditable4.class, 12).selectOne(context);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
assertSame(context, invocation.getArguments()[0]);
ChangeMap changes = (ChangeMap) invocation.getArguments()[1];
assertNull(changes.getChanges().get(new ObjectId("Auditable3", Auditable3.ID_PK_COLUMN, 1)));
return null;
}
}).when(mockListener).onPostCommit(any(ObjectContext.class), any(ChangeMap.class));
a3.removeFromAuditable4s(a41);
a3.addToAuditable4s(a42);
context.commitChanges();
verify(mockListener).onPostCommit(any(ObjectContext.class), any(ChangeMap.class));
}
Aggregations