Skip to content

Commit

Permalink
Merge pull request #170 from bserdar/fix_167
Browse files Browse the repository at this point in the history
More unit tests
  • Loading branch information
bserdar committed Oct 15, 2014
2 parents 23d7d9f + e2f3a8a commit 8bae19d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crud/src/test/java/com/redhat/lightblue/eval/ProjectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,20 @@ public void fieldProjectorTest_includeArrayExcludeFields() throws Exception {
Assert.assertNull(pdoc.get(new Path("field7.1.elemf1")));
Assert.assertEquals("elvalue3_2", pdoc.get(new Path("field7.1.elemf2")).asText());
}

@Test
public void fieldProjectorTest_includeArrayExcludeFields2() throws Exception {
Projection p = EvalTestContext.projectionFromJson("[{'field':'*'},{'field':'field7.*.*'},{'field':'field7.*.elemf1','include':0}]");
Projector projector = Projector.getInstance(p, md);
JsonDoc pdoc = projector.project(jsonDoc, JSON_NODE_FACTORY);
Assert.assertEquals("value1",pdoc.get(new Path("field1")).asText());
Assert.assertEquals("value2",pdoc.get(new Path("field2")).asText());
Assert.assertEquals(3,pdoc.get(new Path("field3")).asInt());
Assert.assertEquals(4.0,pdoc.get(new Path("field4")).asDouble(),0.1);
Assert.assertTrue(pdoc.get(new Path("field5")).asBoolean());
Assert.assertNotNull(pdoc.get(new Path("field6")));
Assert.assertEquals(4, pdoc.get(new Path("field7")).size());
Assert.assertEquals(3, pdoc.get(new Path("field7.0.elemf3")).asInt());
Assert.assertNull(pdoc.get(new Path("field7.0.elemf1")));
}
}

0 comments on commit 8bae19d

Please sign in to comment.