/** Test for {@link Path}. */ @Test public void testSchemaPath() { final SchemaPlus rootSchema = Frameworks.createRootSchema(true); final FrameworkConfig config = Frameworks.newConfigBuilder() .defaultSchema( CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.HR)) .build(); final Path path = Schemas.path(config.getDefaultSchema()); assertThat(path.size(), is(2)); assertThat(path.get(0).left, is("")); assertThat(path.get(1).left, is("hr")); assertThat(path.names().size(), is(1)); assertThat(path.names().get(0), is("hr")); assertThat(path.schemas().size(), is(2)); final Path parent = path.parent(); assertThat(parent.size(), is(1)); assertThat(parent.names().size(), is(0)); final Path grandparent = parent.parent(); assertThat(grandparent.size(), is(0)); try { Object o = grandparent.parent(); fail("expected exception, got " + o); } catch (IllegalArgumentException e) { // ok } }
/** Test for {@link Path}. */ @Test public void testSchemaPath() { final SchemaPlus rootSchema = Frameworks.createRootSchema(true); final FrameworkConfig config = Frameworks.newConfigBuilder() .defaultSchema( CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.HR)) .build(); final Path path = Schemas.path(config.getDefaultSchema()); assertThat(path.size(), is(2)); assertThat(path.get(0).left, is("")); assertThat(path.get(1).left, is("hr")); assertThat(path.names().size(), is(1)); assertThat(path.names().get(0), is("hr")); assertThat(path.schemas().size(), is(2)); final Path parent = path.parent(); assertThat(parent.size(), is(1)); assertThat(parent.names().size(), is(0)); final Path grandparent = parent.parent(); assertThat(grandparent.size(), is(0)); try { Object o = grandparent.parent(); fail("expected exception, got " + o); } catch (IllegalArgumentException e) { // ok } }