String... properties ) {
// Create the expected path ...
PathFactory factory = context.getValueFactories().getPathFactory();
Path expectedPath = parentPath != null ? factory.create(parentPath, path) : factory.create("/" + path);
// Now get the next request and compare the expected and actual ...
CreateNodeRequest request = requests.remove();
Path parentPath = request.under().getPath();
assertThat(parentPath, is(expectedPath.getParent()));
assertThat(request.named(), is(expectedPath.getLastSegment().getName()));
if (properties.length != 0) {
// Create the list of properties ...
Map<Name, Property> expectedProperties = new HashMap<Name, Property>();
for (String propertyString : properties) {
String[] strings = propertyString.split("=");
if (strings.length < 2) continue;
Name name = context.getValueFactories().getNameFactory().create(strings[0]);
Object[] values = new Object[strings.length - 1];
for (int i = 1; i != strings.length; ++i) {
values[i - 1] = strings[i];
}
Property property = context.getPropertyFactory().create(name, values);
expectedProperties.put(name, property);
}
for (Property actual : request.properties()) {
Property expected = expectedProperties.remove(actual.getName());
assertThat("unexpected property: " + actual, expected, is(notNullValue()));
assertThat(actual, is(expected));
}
if (!expectedProperties.isEmpty()) {
StringBuilder msg = new StringBuilder("missing actual properties: ");
boolean isFirst = true;
for (Property expected : expectedProperties.values()) {
if (!isFirst) msg.append(", ");
else isFirst = false;
msg.append(expected.getName());
}
msg.append(" on node ").append(request.under());
System.out.println("Found properties: " + request.properties());
assertThat(msg.toString(), expectedProperties.isEmpty(), is(true));
}
}
}