protected void testResolvePath()

in polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/BaseResolverTest.java [188:271]


  protected void testResolvePath(boolean useCache) {
    this.shouldUseCache = useCache;

    // N1 which exists
    ResolverPath N1 = new ResolverPath(List.of("N1"), PolarisEntityType.NAMESPACE);
    this.resolveDriver(null, "test", N1, null, null);

    // N1/N2 which exists
    ResolverPath N1_N2 = new ResolverPath(List.of("N1", "N2"), PolarisEntityType.NAMESPACE);
    this.resolveDriver(null, "test", N1_N2, null, null);

    // N1/N2/T1 which exists
    ResolverPath N1_N2_T1 =
        new ResolverPath(List.of("N1", "N2", "T1"), PolarisEntityType.TABLE_LIKE);
    this.resolveDriver(this.cache, "test", N1_N2_T1, null, null);

    // N1/N2/T1 which exists
    ResolverPath N1_N2_V1 =
        new ResolverPath(List.of("N1", "N2", "V1"), PolarisEntityType.TABLE_LIKE);
    this.resolveDriver(this.cache, "test", N1_N2_V1, null, null);

    // N5/N6 which exists
    ResolverPath N5_N6 = new ResolverPath(List.of("N5", "N6"), PolarisEntityType.NAMESPACE);
    this.resolveDriver(this.cache, "test", N5_N6, null, null);

    // N5/N6/T5 which exists
    ResolverPath N5_N6_T5 =
        new ResolverPath(List.of("N5", "N6", "T5"), PolarisEntityType.TABLE_LIKE);
    this.resolveDriver(this.cache, "test", N5_N6_T5, null, null);

    // N7/N8 which exists
    ResolverPath N7_N8 = new ResolverPath(List.of("N7", "N8"), PolarisEntityType.NAMESPACE);
    this.resolveDriver(this.cache, "test", N7_N8, null, null);

    // N7/N8/POL1 which exists
    ResolverPath N7_N8_POL1 =
        new ResolverPath(List.of("N7", "N8", "POL1"), PolarisEntityType.POLICY);
    this.resolveDriver(this.cache, "test", N7_N8_POL1, null, null);

    // N7/POL3 which exists
    ResolverPath N7_POL3 = new ResolverPath(List.of("N7", "POL3"), PolarisEntityType.POLICY);
    this.resolveDriver(this.cache, "test", N7_POL3, null, null);

    // Error scenarios: N5/N6/T8 which does not exists
    ResolverPath N5_N6_T8 =
        new ResolverPath(List.of("N5", "N6", "T8"), PolarisEntityType.TABLE_LIKE);
    this.resolveDriver(
        this.cache,
        "test",
        N5_N6_T8,
        null,
        ResolverStatus.StatusEnum.PATH_COULD_NOT_BE_FULLY_RESOLVED);

    // Error scenarios: N8/N6/T8 which does not exists
    ResolverPath N8_N6_T8 =
        new ResolverPath(List.of("N8", "N6", "T8"), PolarisEntityType.TABLE_LIKE);
    this.resolveDriver(
        this.cache,
        "test",
        N8_N6_T8,
        null,
        ResolverStatus.StatusEnum.PATH_COULD_NOT_BE_FULLY_RESOLVED);

    // now test multiple paths
    this.resolveDriver(
        this.cache, "test", null, List.of(N1, N5_N6, N1, N1_N2, N5_N6_T5, N1_N2), null);
    this.resolveDriver(
        this.cache,
        "test",
        null,
        List.of(N1, N5_N6_T8, N5_N6_T5, N1_N2),
        ResolverStatus.StatusEnum.PATH_COULD_NOT_BE_FULLY_RESOLVED);

    // except if the optional flag is specified
    N5_N6_T8 = new ResolverPath(List.of("N5", "N6", "T8"), PolarisEntityType.TABLE_LIKE, true);
    Resolver resolver =
        this.resolveDriver(this.cache, "test", null, List.of(N1, N5_N6_T8, N5_N6_T5, N1_N2), null);
    // get all the resolved paths
    List<List<ResolvedPolarisEntity>> resolvedPath = resolver.getResolvedPaths();
    Assertions.assertThat(resolvedPath.get(0)).hasSize(1);
    Assertions.assertThat(resolvedPath.get(1)).hasSize(2);
    Assertions.assertThat(resolvedPath.get(2)).hasSize(3);
    Assertions.assertThat(resolvedPath.get(3)).hasSize(2);
  }