assertThat(path, hasSegments(pathFactory, "a", "b", "c"));
}
@Test
public void shouldConvertPathToString() {
TextEncoder encoder = new Jsr283Encoder();
TextEncoder delimEncoder = new TextEncoder() {
@Override
public String encode( String text ) {
if ("/".equals(text)) return "\\/";
if (":".equals(text)) return "\\:";
if ("{".equals(text)) return "\\{";
if ("}".equals(text)) return "\\}";
return text;
}
};
Path path = pathFactory.create("a/b/c");
assertThat(path.getString(registry), is("a/b/c"));
assertThat(path.getString(registry, encoder), is("a/b/c"));
assertThat(path.getString(registry, encoder, delimEncoder), is("a\\/b\\/c"));
path = pathFactory.create("/a/b/c");
assertThat(path.getString(registry), is("/a/b/c"));
assertThat(path.getString(registry, encoder), is("/a/b/c"));
assertThat(path.getString(registry, encoder, delimEncoder), is("\\/a\\/b\\/c"));
path = pathFactory.create("/mode:a/b/c");
assertThat(path.getString(encoder), is("/{" + encoder.encode(ModeShapeLexicon.Namespace.URI) + "}a/{}b/{}c"));
assertThat(path.getString(null, encoder, delimEncoder), is("\\/mode:a\\/\\{\\}b\\/\\{\\}c"));
assertThat(path.getString(registry), is("/mode:a/b/c"));
assertThat(path.getString(registry, encoder), is("/mode:a/b/c"));
assertThat(path.getString(registry, encoder, delimEncoder), is("\\/mode\\:a\\/b\\/c"));
}