QualifierAnalyzer { public String unqualified(String... parts) { return unqualified(QualifiedName.of(Arrays.asList(parts))); }  String unqualified(String... parts); String unqualified(QualifiedName fullName);  }
@Test void should_return_original_name_if_no_qualifier() { assertEquals("integer_value", qualifierAnalyzer.unqualified("integer_value")); }
@Test void should_report_error_if_qualifier_is_not_index() { runInScope(new Symbol(Namespace.FIELD_NAME, "a"), ARRAY, () -> { SyntaxCheckException error = assertThrows(SyntaxCheckException.class, () -> qualifierAnalyzer.unqualified("a", "integer_value")); assertEquals("The qualifier [a] of qualified name [a.integer_value] " + "must be an index name or its alias", error.getMessage()); }); }
@Test void should_report_error_if_qualifier_is_not_exist() { SyntaxCheckException error = assertThrows(SyntaxCheckException.class, () -> qualifierAnalyzer.unqualified("a", "integer_value")); assertEquals( "The qualifier [a] of qualified name [a.integer_value] must be an index name or its alias", error.getMessage()); }
@Test void should_return_qualified_name_if_qualifier_is_index() { runInScope(new Symbol(Namespace.INDEX_NAME, "a"), STRUCT, () -> assertEquals("integer_value", qualifierAnalyzer.unqualified("a", "integer_value")) ); }
@Test void should_report_error_if_more_parts_in_qualified_name() { runInScope(new Symbol(Namespace.INDEX_NAME, "a"), STRUCT, () -> qualifierAnalyzer.unqualified("a", "integer_value", "invalid") ); }