Search in sources :

Example 1 with Values

use of org.apache.cayenne.access.flush.operation.Values in project cayenne by apache.

the class ArcValuesCreationHandlerTest method setup.

@SuppressWarnings("unchecked")
@Before
public void setup() {
    factory = mock(DbRowOpFactory.class);
    handler = new ArcValuesCreationHandler(factory, DbRowOpType.INSERT);
    dbRowOp = mock(InsertDbRowOp.class);
    values = new Values(dbRowOp, false);
    ObjectDiff diff = mock(ObjectDiff.class);
    ClassDescriptor descriptor = mock(ClassDescriptor.class);
    ObjEntity entity = mock(ObjEntity.class);
    ObjRelationship relationship = mock(ObjRelationship.class);
    DbRelationship dbRelationship = mock(DbRelationship.class);
    ObjectStore store = mock(ObjectStore.class);
    Persistent object = mock(Persistent.class);
    when(relationship.getDbRelationships()).thenReturn(Collections.singletonList(dbRelationship));
    when(entity.getRelationship(anyString())).thenReturn(relationship);
    when(descriptor.getEntity()).thenReturn(entity);
    when(dbRowOp.accept(any(DbRowOpVisitor.class))).thenCallRealMethod();
    when(dbRowOp.getValues()).thenReturn(values);
    when(factory.getDiff()).thenReturn(diff);
    when(factory.getDescriptor()).thenReturn(descriptor);
    when(factory.getStore()).thenReturn(store);
    when(factory.getObject()).thenReturn(object);
    when(factory.getOrCreate(isNull(), any(ObjectId.class), any(DbRowOpType.class))).thenReturn(dbRowOp);
}
Also used : InsertDbRowOp(org.apache.cayenne.access.flush.operation.InsertDbRowOp) ObjRelationship(org.apache.cayenne.map.ObjRelationship) ObjectStore(org.apache.cayenne.access.ObjectStore) DbRowOpVisitor(org.apache.cayenne.access.flush.operation.DbRowOpVisitor) ClassDescriptor(org.apache.cayenne.reflect.ClassDescriptor) ObjectDiff(org.apache.cayenne.access.ObjectDiff) ObjectId(org.apache.cayenne.ObjectId) DbRowOpType(org.apache.cayenne.access.flush.operation.DbRowOpType) Values(org.apache.cayenne.access.flush.operation.Values) Persistent(org.apache.cayenne.Persistent) ObjEntity(org.apache.cayenne.map.ObjEntity) DbRelationship(org.apache.cayenne.map.DbRelationship) Before(org.junit.Before)

Aggregations

ObjectId (org.apache.cayenne.ObjectId)1 Persistent (org.apache.cayenne.Persistent)1 ObjectDiff (org.apache.cayenne.access.ObjectDiff)1 ObjectStore (org.apache.cayenne.access.ObjectStore)1 DbRowOpType (org.apache.cayenne.access.flush.operation.DbRowOpType)1 DbRowOpVisitor (org.apache.cayenne.access.flush.operation.DbRowOpVisitor)1 InsertDbRowOp (org.apache.cayenne.access.flush.operation.InsertDbRowOp)1 Values (org.apache.cayenne.access.flush.operation.Values)1 DbRelationship (org.apache.cayenne.map.DbRelationship)1 ObjEntity (org.apache.cayenne.map.ObjEntity)1 ObjRelationship (org.apache.cayenne.map.ObjRelationship)1 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)1 Before (org.junit.Before)1