@Test
    public void shouldHaveSubPathSupport() {
        PATH_SUPPLIERS.forEach(supplier -> {
            Path path = supplier.get();
            path = path.extend("marko", Collections.singleton("a"));
            path = path.extend("stephen", Collections.singleton("b"));
            path = path.extend("matthias", new HashSet<>(Arrays.asList("c", "x")));
            path = path.extend("bob", Collections.singleton("d"));
            assertEquals(4, path.size());
            assertEquals(4, path.objects().size());
            assertEquals(4, path.labels().size());
            ///
            Path subPath = path.subPath("b", "c");
            assertEquals(2, subPath.size());
            assertEquals(2, subPath.objects().size());
            assertEquals(2, subPath.labels().size());
            assertEquals("stephen", subPath.objects().get(0));
            assertEquals("matthias", subPath.objects().get(1));
            assertTrue(subPath.labels().get(0).contains("b"));
            assertEquals(1, subPath.labels().get(0).size());
            assertTrue(subPath.labels().get(1).contains("c"));
            assertTrue(subPath.labels().get(1).contains("x"));
            assertEquals(2, subPath.labels().get(1).size());
            ///
            subPath = path.subPath("b", "b");
            assertEquals(1, subPath.size());
            assertEquals(1, subPath.objects().size());
            assertEquals(1, subPath.labels().size());
            assertEquals("stephen", subPath.objects().get(0));
            ///
            subPath = path.subPath("b", "b");
            assertEquals(1, subPath.size());
            assertEquals(1, subPath.objects().size());
            assertEquals(1, subPath.labels().size());
            assertEquals("stephen", subPath.objects().get(0));
            ///
            subPath = path.subPath("c", "d");
            assertEquals(2, subPath.size());
            assertEquals(2, subPath.objects().size());
            assertEquals(2, subPath.labels().size());
            assertEquals("matthias", subPath.objects().get(0));
            assertEquals("bob", subPath.objects().get(1));
            assertTrue(subPath.labels().get(0).contains("c"));
            assertTrue(subPath.labels().get(0).contains("x"));
            assertEquals(2, subPath.labels().get(0).size());
            assertTrue(subPath.labels().get(1).contains("d"));
            assertEquals(1, subPath.labels().get(1).size());
            ///
            subPath = path.subPath("c", null);
            assertEquals(2, subPath.size());
            assertEquals(2, subPath.objects().size());
            assertEquals(2, subPath.labels().size());
            assertEquals("matthias", subPath.objects().get(0));
            assertEquals("bob", subPath.objects().get(1));
            assertTrue(subPath.labels().get(0).contains("c"));
            assertTrue(subPath.labels().get(0).contains("x"));
            assertEquals(2, subPath.labels().get(0).size());
            assertTrue(subPath.labels().get(1).contains("d"));
            assertEquals(1, subPath.labels().get(1).size());
            ///
            subPath = path.subPath("a", "d");
            assertEquals(4, subPath.size());
            assertEquals(4, subPath.objects().size());
            assertEquals(4, subPath.labels().size());
            ///
            subPath = path.subPath(null, "d");
            assertEquals(4, subPath.size());
            assertEquals(4, subPath.objects().size());
            assertEquals(4, subPath.labels().size());
            ///
            try {
                subPath = path.subPath("d", "a");
                fail("Path labels must be ordered along path");
            } catch (final IllegalArgumentException e) {
                assertEquals(Path.Exceptions.couldNotIsolatedSubPath("d", "a").getMessage(), e.getMessage());
            }
            ///
            try {
                subPath = path.subPath("a", "e");
                fail("End path label was not found");
            } catch (final IllegalArgumentException e) {
                assertEquals(Path.Exceptions.couldNotLocatePathToLabel("e").getMessage(), e.getMessage());
            }
            ///
            try {
                subPath = path.subPath("e", "b");
                fail("Start path label was not found");
            } catch (final IllegalArgumentException e) {
                assertEquals(Path.Exceptions.couldNotLocatePathFromLabel("e").getMessage(), e.getMessage());
            }
        });
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/PathTest.java