}
@Test
public void testParse_Array() throws BodyParseException {
RequestBodyParser parser = new JsonRequestBodyParser();
RequestBody body = parser.parse(arrayJson).iterator().next();
Set<NamedPropertySet> setProps = body.getNamedPropertySets();
assertEquals(3, setProps.size());
boolean cluster1Matches = false;
boolean cluster2Matches = false;
boolean cluster3Matches = false;
Map<String, String> mapCluster1 = new HashMap<String, String>();
mapCluster1.put(PropertyHelper.getPropertyId("Clusters", "cluster_name"), "unitTestCluster1");
Map<String, String> mapCluster2 = new HashMap<String, String>();
mapCluster2.put(PropertyHelper.getPropertyId("Clusters", "cluster_name"), "unitTestCluster2");
mapCluster2.put(PropertyHelper.getPropertyId("Clusters", "property1"), "prop1Value");
Map<String, String> mapCluster3 = new HashMap<String, String>();
mapCluster3.put(PropertyHelper.getPropertyId("Clusters", "cluster_name"), "unitTestCluster3");
mapCluster3.put(PropertyHelper.getPropertyId("Clusters/Category", "property2"), "prop2Value");
for (NamedPropertySet propertySet : setProps) {
assertEquals("", propertySet.getName());
Map<String, Object> mapProps = propertySet.getProperties();
if (mapProps.equals(mapCluster1)) {
cluster1Matches = true;
} else if (mapProps.equals(mapCluster2)) {
cluster2Matches = true;
} else if (mapProps.equals(mapCluster3)) {
cluster3Matches = true;
}
}
assertTrue(cluster1Matches);
assertTrue(cluster2Matches);
assertTrue(cluster3Matches);
//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(3, setProps2.size());
assertEquals(setProps, setProps2);
}