@Test
public void testParse___QueryPost_multipleSubResTypes() throws BodyParseException {

  RequestBodyParser parser = new JsonRequestBodyParser();
  RequestBody body = parser.parse(queryPostMultipleSubResourcesJson).iterator().next();
  Set<NamedPropertySet> setProperties = body.getNamedPropertySets();
  assertEquals(1, setProperties.size());
  boolean contains1 = false;
  boolean contains2 = false;
  for (NamedPropertySet ps : setProperties) {
    Map<String, Object> mapProps = ps.getProperties();
    for (Map.Entry<String, Object> entry : mapProps.entrySet()) {
      Set<Map<String, Object>> set = (Set<Map<String, Object>>) entry.getValue();
      for (Map<String, Object> map : set) {
        String serviceName = (String) map.get("ServiceInfo/service_name");
        if (serviceName.equals("unitTestService1")) {
          assertEquals("foo", entry.getKey());
          assertEquals(1, map.size());
          contains1 = true;
        } else if (serviceName.equals("unitTestService2")) {
          assertEquals("bar", entry.getKey());
          assertEquals("prop2Value", map.get("ServiceInfo/Category/property2"));
          assertEquals(2, map.size());
          contains2 = true;
        } else {
          fail("Unexpected service name");
        }
      }
    }
  }
  assertTrue(contains1);
  assertTrue(contains2);
  //assert body is correct by checking that properties match
  String b = body.getBody();
  body = parser.parse(b).iterator().next();
  Set<NamedPropertySet> setProps2 = body.getNamedPropertySets();
  assertEquals(1, setProps2.size());
  assertEquals(setProperties, setProps2);
}