use of org.apache.cayenne.ObjectId in project cayenne by apache.
the class ExpressionTest method testAppendAsEJBQL_PersistentParamater.
@Test
public void testAppendAsEJBQL_PersistentParamater() throws IOException {
Artist a = new Artist();
ObjectId aId = new ObjectId("Artist", Artist.ARTIST_ID_PK_COLUMN, 1);
a.setObjectId(aId);
Expression e = ExpressionFactory.matchExp("artist", a);
StringBuilder buffer = new StringBuilder();
e.appendAsEJBQL(buffer, "x");
String ejbql = buffer.toString();
assertEquals("x.artist = 1", ejbql);
}
use of org.apache.cayenne.ObjectId in project cayenne by apache.
the class ASTListTest method testEquals.
@Test
public void testEquals() throws Exception {
ObjectId objectId = new ObjectId("Artist", "ARTIST_ID", 1);
Persistent artist = mock(Persistent.class);
when(artist.getObjectId()).thenReturn(objectId);
ASTList exp = new ASTList(Collections.singletonList(artist));
List<Persistent> collection = new ArrayList<>();
collection.add(artist);
ASTList exp2 = new ASTList(collection);
ASTList exp3 = new ASTList(Collections.emptyList());
assertEquals(exp, exp2);
assertNotEquals(exp, exp3);
}
use of org.apache.cayenne.ObjectId in project cayenne by apache.
the class ASTListTest method testConstructorWithCollection.
@Test
public void testConstructorWithCollection() {
ObjectId objectId = new ObjectId("Artist", "ARTIST_ID", 1);
Persistent artist = mock(Persistent.class);
when(artist.getObjectId()).thenReturn(objectId);
ASTList exp = new ASTList(Collections.singletonList(artist));
assertNotNull(exp.getOperand(0));
List<Persistent> collection = new ArrayList<>();
collection.add(artist);
exp = new ASTList(collection);
assertNotNull(exp.getOperand(0));
}
use of org.apache.cayenne.ObjectId in project cayenne by apache.
the class ObjectIdQueryTest method testMetadata.
@Test
public void testMetadata() {
ObjectIdQuery q1 = new ObjectIdQuery(new ObjectId("abc", "a", 1), true, ObjectIdQuery.CACHE_REFRESH);
assertTrue(q1.isFetchAllowed());
assertTrue(q1.isFetchMandatory());
QueryMetadata md1 = q1.getMetaData(null);
assertTrue(md1.isFetchingDataRows());
ObjectIdQuery q2 = new ObjectIdQuery(new ObjectId("abc", "a", 1), false, ObjectIdQuery.CACHE);
assertTrue(q2.isFetchAllowed());
assertFalse(q2.isFetchMandatory());
QueryMetadata md2 = q2.getMetaData(null);
assertFalse(md2.isFetchingDataRows());
ObjectIdQuery q3 = new ObjectIdQuery(new ObjectId("abc", "a", 1), false, ObjectIdQuery.CACHE_NOREFRESH);
assertFalse(q3.isFetchAllowed());
assertFalse(q3.isFetchMandatory());
QueryMetadata md3 = q3.getMetaData(null);
assertFalse(md3.isFetchingDataRows());
}
use of org.apache.cayenne.ObjectId in project cayenne by apache.
the class ObjectIdQueryTest method testSerializability.
@Test
public void testSerializability() throws Exception {
ObjectId oid = new ObjectId("test", "a", "b");
ObjectIdQuery query = new ObjectIdQuery(oid);
Object o = Util.cloneViaSerialization(query);
assertNotNull(o);
assertTrue(o instanceof ObjectIdQuery);
assertEquals(oid, ((ObjectIdQuery) o).getObjectId());
}
Aggregations