public void testBasicMapField() throws IOException
{
HashMap<Object,Object> map = new HashMap<Object, Object>();
map.put("someKey", "someValue");
map.put("anotherKey", "anotherValue");
BasicTestDataLeaf input = new BasicTestDataLeaf();
input.setId(10);
input.setName("name");
input.setOther("other");
map.put("aThirdKey", input);
ObjectMapHierarchicalModelImpl model = new ObjectMapHierarchicalModelImpl();
FieldSelector selector = new FieldSelector();
selector.register( "anotherKey", new FieldSelector() );
selector.register( "aThirdKey", new FieldSelector() );
resultTraverser.traverse( map, new CompositeSelector( resolver.getBaseSelector(), selector ), model, requestContext );
Map<String, Object> objectTree = model.getUnderlyingModel();
// "someKey" should not be selected from map
Assert.assertEquals( null, objectTree.get( "someKey" ) );
// "anotherKey" should be selected from map and has primitive value
Assert.assertEquals( "anotherValue", objectTree.get( "anotherKey" ) );
// "aThirdKey" should be selected but only @Core fields of pojo
Map<?,?> actualPojo = (Map<?,?>) objectTree.get("aThirdKey");
Assert.assertEquals( input.getId(), actualPojo.get("id"));
Assert.assertEquals( input.getName(), actualPojo.get("name"));
Assert.assertEquals(null, actualPojo.get("other"));
}