use of org.mongodb.morphia.query.QueryImpl in project morphia by mongodb.
the class EmbeddedReferenceType method testQueryFormat.
@Test
@SuppressWarnings("deprecation")
public void testQueryFormat() {
Assume.assumeTrue("This test requires Java 8", JAVA_8);
Query<ReferenceType> query = getDs().find(ReferenceType.class).field("id").equal(new ObjectId(0, 0, (short) 0, 0)).field("referenceType").equal(new ReferenceType(2, "far")).field("embeddedType").equal(new EmbeddedReferenceType(3, "strikes")).field("string").equal("some value").field("embeddedArray").elemMatch(getDs().find(EmbeddedReferenceType.class).filter("number", 3).filter("text", "strikes")).field("embeddedSet").elemMatch(getDs().find(EmbeddedReferenceType.class).filter("number", 3).filter("text", "strikes")).field("embeddedList").elemMatch(getDs().find(EmbeddedReferenceType.class).filter("number", 3).filter("text", "strikes")).field("map.bar").equal(new EmbeddedReferenceType(1, "chance")).field("mapOfList.bar").in(singletonList(new EmbeddedReferenceType(1, "chance"))).field("mapOfList.foo").elemMatch(getDs().find(EmbeddedReferenceType.class).filter("number", 1).filter("text", "chance")).field("selfReference").equal(new ReferenceType(1, "blah")).field("mixedTypeList").elemMatch(getDs().find(EmbeddedReferenceType.class).filter("number", 3).filter("text", "strikes")).field("mixedTypeList").in(singletonList(new EmbeddedReferenceType(1, "chance"))).field("mixedTypeMap.foo").equal(new ReferenceType(3, "strikes")).field("mixedTypeMap.bar").equal(new EmbeddedReferenceType(3, "strikes")).field("mixedTypeMapOfList.bar").in(singletonList(new EmbeddedReferenceType(1, "chance"))).field("mixedTypeMapOfList.foo").elemMatch(getDs().find(EmbeddedReferenceType.class).filter("number", 3).filter("text", "strikes")).field("referenceMap.foo").equal(new ReferenceType(1, "chance")).field("referenceMap.bar").equal(new EmbeddedReferenceType(1, "chance"));
DBObject dbObject = ((QueryImpl) query).getQueryObject();
Assert.assertEquals(BasicDBObject.parse(readFully("/QueryStructure.json")), dbObject);
}
Aggregations