use of org.mongodb.morphia.TestMapper.UsesCustomIdObject in project morphia by mongodb.
the class TestQuery method testComplexIdQuery.
@Test
public void testComplexIdQuery() {
final CustomId cId = new CustomId();
cId.setId(new ObjectId());
cId.setType("banker");
final UsesCustomIdObject object = new UsesCustomIdObject();
object.setId(cId);
object.setText("hllo");
getDs().save(object);
assertNotNull(getDs().find(UsesCustomIdObject.class).filter("_id.type", "banker").get());
assertNotNull(getDs().find(UsesCustomIdObject.class).field("_id").hasAnyOf(singletonList(cId)).get());
}
use of org.mongodb.morphia.TestMapper.UsesCustomIdObject in project morphia by mongodb.
the class TestQuery method testComplexIdQueryWithRenamedField.
@Test
public void testComplexIdQueryWithRenamedField() {
final CustomId cId = new CustomId();
cId.setId(new ObjectId());
cId.setType("banker");
final UsesCustomIdObject object = new UsesCustomIdObject();
object.setId(cId);
object.setText("hllo");
getDs().save(object);
assertNotNull(getDs().find(UsesCustomIdObject.class).filter("_id.t", "banker").get());
}
use of org.mongodb.morphia.TestMapper.UsesCustomIdObject in project morphia by mongodb.
the class TestQuery method testQBE.
@Test
public void testQBE() {
final CustomId cId = new CustomId();
cId.setId(new ObjectId());
cId.setType("banker");
final UsesCustomIdObject object = new UsesCustomIdObject();
object.setId(cId);
object.setText("hllo");
getDs().save(object);
final UsesCustomIdObject loaded;
// Add back if/when query by example for embedded fields is supported (require dotting each field).
// CustomId exId = new CustomId();
// exId.type = cId.type;
// loaded = getDs().find(UsesCustomIdObject.class, "_id", exId).get();
// assertNotNull(loaded);
final UsesCustomIdObject ex = new UsesCustomIdObject();
ex.setText(object.getText());
loaded = getDs().queryByExample(ex).get();
assertNotNull(loaded);
}
Aggregations