PathValueFactory extends AbstractValueFactory<Path> implements PathFactory { @Override public Path create( String value ) { return create(value, getDecoder()); } PathValueFactory( TextDecoder decoder,
                             ValueFactories factories ); @Override PathFactory with( ValueFactories valueFactories ); @Override Path createRootPath(); @Override Path create( String value ); @Override Path create( final String value,
                        TextDecoder decoder ); @Override Path create( int value ); @Override Path create( long value ); @Override Path create( boolean value ); @Override Path create( float value ); @Override Path create( double value ); @Override Path create( BigDecimal value ); @Override Path create( Calendar value ); @Override Path create( Date value ); @Override Path create( DateTime value ); @Override Path create( Name value ); @Override Path create( Path value ); @Override Path create( Path.Segment value ); @Override Path createAbsolutePath( Name... segmentNames ); @Override Path createAbsolutePath( Segment... segments ); @Override Path createAbsolutePath( Iterable<Segment> segments ); @Override Path createRelativePath(); @Override Path createRelativePath( Name... segmentNames ); @Override Path createRelativePath( Segment... segments ); @Override Path createRelativePath( Iterable<Segment> segments ); @Override Path create( Path parentPath,
                        Path childPath ); @Override Path create( Path parentPath,
                        Name segmentName,
                        int index ); @Override Path create( Path parentPath,
                        String segmentName,
                        int index ); @Override Path create( Path parentPath,
                        Name... segmentNames ); @Override Path create( Path parentPath,
                        Segment... segments ); @Override Path create( Path parentPath,
                        Iterable<Segment> segments ); @Override Path create( Path parentPath,
                        String subpath ); @Override Segment createSegment( Name segmentName ); @Override Segment createSegment( Name segmentName,
                                  int index ); @Override Segment createSegment( String segmentName ); @Override Segment createSegment( String segmentName,
                                  TextDecoder decoder ); @Override Segment createSegment( String segmentName,
                                  int index ); @Override Path create( Reference value ); @Override Path create( URI value ); @Override Path create( UUID value ); @Override Path create( NodeKey value ); @Override Path create( byte[] value ); @Override Path create( BinaryValue value ); @Override Path create( InputStream stream ); @Override Path[] createEmptyArray( int length );  }
@Test public void shouldCreateFromStringWithAbsolutePathAndNoParentOrSelfReferences() { path = factory.create("/a/b/c/d/dna:e/dna:f"); assertThat(path, hasSegments(factory, "a", "b", "c", "d", "dna:e", "dna:f")); }
@Test public void shouldCreateFromStringWithRelativePathAndNoParentOrSelfReferences() { path = factory.create("a/b/c/d/dna:e/dna:f"); assertThat(path, hasSegments(factory, "a", "b", "c", "d", "dna:e", "dna:f")); }
@Test public void shouldCreateFromStringWithAbsolutePathAndParentReference() { path = factory.create("/a/b/c/../dna:e/dna:f"); assertThat(path, hasSegments(factory, "a", "b", "c", "..", "dna:e", "dna:f")); }
@Test public void shouldCreateFromStringWithRelativePathAndParentReference() { path = factory.create("a/b/c/../dna:e/dna:f"); assertThat(path, hasSegments(factory, "a", "b", "c", "..", "dna:e", "dna:f")); }
@Test public void shouldCreateFromStringWithAbsolutePathAndSelfReference() { path = factory.create("/a/b/c/./dna:e/dna:f"); assertThat(path, hasSegments(factory, "a", "b", "c", ".", "dna:e", "dna:f")); }
@Test public void shouldCreateFromStringWithRelativePathAndSelfReference() { path = factory.create("a/b/c/./dna:e/dna:f"); assertThat(path, hasSegments(factory, "a", "b", "c", ".", "dna:e", "dna:f")); }
@Test public void shouldCreateFromStringWithRelativePathBeginningWithSelfReference() { path = factory.create("./a/b/c/./dna:e/dna:f"); assertThat(path, hasSegments(factory, ".", "a", "b", "c", ".", "dna:e", "dna:f")); }
@Test public void shouldCreateEquivalentPathsWhetherOrNotThereIsATrailingDelimiter() { path = factory.create("/a/b/c/d/dna:e/dna:f"); path2 = factory.create("/a/b/c/d/dna:e/dna:f/"); assertThat(path.equals(path2), is(true)); assertThat(path.compareTo(path2), is(0)); }
@Test public void shouldCreateIteratorOverValuesWhenSuppliedIteratorOfUnknownObjects() { List<String> values = new ArrayList<String>(); for (int i = 0; i != 10; ++i) { values.add("/a/b/c/d/dna:e/dna:f" + i); } Iterator<Path> iter = factory.create(values.iterator()); Iterator<String> valueIter = values.iterator(); while (iter.hasNext()) { assertThat(iter.next(), is(factory.create(valueIter.next()))); } }