### Question:
BasicPath extends AbstractPath { public boolean isNormalized() { return this.normalized; } BasicPath( List<Segment> segments,
                      boolean absolute ); Path getAncestor( int degree ); List<Segment> getSegmentsList(); boolean isAbsolute(); boolean isNormalized(); boolean isRoot(); int size(); static final Path EMPTY_RELATIVE; static final Path SELF_PATH; static final Path PARENT_PATH; }### Answer:
@Test public void shouldAlreadyBeNormalizedIfPathContainsNoParentOrSelfReferences() { assertThat(pathFactory.create("/a/b/c/d/e").isNormalized(), is(true)); assertThat(pathFactory.create("a/b/c/d/e").isNormalized(), is(true)); assertThat(pathFactory.create("a").isNormalized(), is(true)); assertThat(pathFactory.create("/a").isNormalized(), is(true)); assertThat(ROOT.isNormalized(), is(true)); }
@Test public void shouldNotBeNormalizedIfPathContainsParentOrSelfReferences() { assertThat(pathFactory.create("/a/b/c/../d/./e/../..").isNormalized(), is(false)); assertThat(pathFactory.create("a/b/c/../d/./e/../..").isNormalized(), is(false)); assertThat(pathFactory.create("a/b/c/./d").isNormalized(), is(false)); assertThat(pathFactory.create("/a/b/c/../d").isNormalized(), is(false)); assertThat(pathFactory.create(".").isNormalized(), is(false)); assertThat(pathFactory.create("/.").isNormalized(), is(false)); }
@Test( expected = InvalidPathException.class ) public void shouldFailToReturnNormalizedPathIfPathContainsReferencesToParentsAboveRoot() { path = pathFactory.create("/a/../../../.."); assertThat(path.isNormalized(), is(false)); path.getNormalizedPath(); }
@Test public void shouldReturnRootPathAsTheNormalizedPathForAnAbsolutePathWithZeroSegmentsAfterParentAndSelfReferencesRemoved() { path = pathFactory.create("/a/../b/../c/../"); assertThat(path.isNormalized(), is(false)); assertThat(path.getNormalizedPath(), is(ROOT)); }