### Question:
Identifiers { public static IdentifierTransformer transformer(Identifier base) { return new IdentifierTransformer(base); } private  Identifiers(); static Identifier withNamespace(Identifier base, String namespace); static Identifier withPath(Identifier base, String path); static Identifier prefixPath(Identifier base, String prefix); static Identifier suffixPath(Identifier base, String suffix); static Identifier truncatePath(Identifier base, int start); static Identifier truncatePath(Identifier base, int start, int end); static Identifier replacePathSegments(Identifier base, int start, int end, String replacement); static Identifier remove(Identifier base, int start, int end); static IdentifierTransformer transformer(Identifier base);  }### Answer:
@Test void lastSegmentIndexOf() { Identifier base = new Identifier("foo:bar/baz/bar"); assertEquals(2, Identifiers.transformer(base).lastSegmentIndexOf("bar")); assertEquals(1, Identifiers.transformer(base).lastSegmentIndexOf("baz")); assertEquals(-1, Identifiers.transformer(base).lastSegmentIndexOf("qux")); }
@Test void getPathSegment() { Identifier base = new Identifier("foo:bar/baz/qux"); assertEquals("bar", Identifiers.transformer(base).getPathSegment(0)); assertEquals("baz", Identifiers.transformer(base).getPathSegment(1)); assertEquals("qux", Identifiers.transformer(base).getPathSegment(2)); assertThrows(IndexOutOfBoundsException.class, () -> Identifiers.transformer(base).getPathSegment(-1)); }
@Test void segmentIndexOf() { Identifier base = new Identifier("foo:bar/baz/bar"); assertEquals(0, Identifiers.transformer(base).segmentIndexOf("bar")); assertEquals(1, Identifiers.transformer(base).segmentIndexOf("baz")); assertEquals(-1, Identifiers.transformer(base).segmentIndexOf("qux")); }