<commit_before>/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
package org.elasticsearch.xpack.sql.plan.logical;

import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.sql.plan.TableIdentifier;
import org.elasticsearch.xpack.sql.tree.Location;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode;

public class UnresolvedRelationTests extends ESTestCase {
    public void testEqualsAndHashCode() {
        Location location = new Location(between(1, 1000), between(1, 1000));
        TableIdentifier table = new TableIdentifier(location, randomAlphaOfLength(5));
        String alias = randomBoolean() ? null : randomAlphaOfLength(5);
        String unresolvedMessage = randomAlphaOfLength(5);
        UnresolvedRelation relation = new UnresolvedRelation(location, table, alias, unresolvedMessage);
        List<Function<UnresolvedRelation, UnresolvedRelation>> mutators = new ArrayList<>();
        mutators.add(r -> new UnresolvedRelation(
            new Location(r.location().getLineNumber() + 1, r.location().getColumnNumber()), r.table(), r.alias(), r.unresolvedMessage()));
        mutators.add(r -> new UnresolvedRelation(
            r.location(), new TableIdentifier(r.location(), r.table().index() + "m"), r.alias(), r.unresolvedMessage()));
        mutators.add(r -> new UnresolvedRelation(
            r.location(),
            r.table(),
            randomValueOtherThan(r.alias(), () -> randomBoolean() ? null : randomAlphaOfLength(5)),
            r.unresolvedMessage()));
        mutators.add(r -> new UnresolvedRelation(
            r.location(), r.table(), r.alias(), randomValueOtherThan(r.unresolvedMessage(), () -> randomAlphaOfLength(5))));
        checkEqualsAndHashCode(relation,
            r -> new UnresolvedRelation(r.location(), r.table(), r.alias(), r.unresolvedMessage()),
            r -> randomFrom(mutators).apply(r));
    }
}<commit_msg>SQL: Fix test for UnresolvedRelation<commit_after>/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
package org.elasticsearch.xpack.sql.plan.logical;

import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.sql.plan.TableIdentifier;
import org.elasticsearch.xpack.sql.tree.Location;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;

import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode;

public class UnresolvedRelationTests extends ESTestCase {
    public void testEqualsAndHashCode() {
        Location location = new Location(between(1, 1000), between(1, 1000));
        TableIdentifier table = new TableIdentifier(location, randomAlphaOfLength(5));
        String alias = randomBoolean() ? null : randomAlphaOfLength(5);
        String unresolvedMessage = randomAlphaOfLength(5);
        UnresolvedRelation relation = new UnresolvedRelation(location, table, alias, unresolvedMessage);
        List<Function<UnresolvedRelation, UnresolvedRelation>> mutators = new ArrayList<>();
        mutators.add(r -> new UnresolvedRelation(
            new Location(r.location().getLineNumber() + 1, r.location().getColumnNumber()),
            r.table(),
            r.alias(),
            r.unresolvedMessage()));
        mutators.add(r -> new UnresolvedRelation(
            r.location(),
            new TableIdentifier(r.location(), r.table().index() + "m"),
            r.alias(),
            r.unresolvedMessage()));
        mutators.add(r -> new UnresolvedRelation(
            r.location(),
            r.table(),
            randomValueOtherThanMany(
                a -> Objects.equals(a, r.alias()),
                () -> randomBoolean() ? null : randomAlphaOfLength(5)),
            r.unresolvedMessage()));
        mutators.add(r -> new UnresolvedRelation(
            r.location(),
            r.table(),
            r.alias(),
            randomValueOtherThan(r.unresolvedMessage(), () -> randomAlphaOfLength(5))));
        checkEqualsAndHashCode(relation,
            r -> new UnresolvedRelation(r.location(), r.table(), r.alias(), r.unresolvedMessage()),
            r -> randomFrom(mutators).apply(r));
    }
}
{'fraction_non_alphanumeric': 0.12265169509825091, 'fraction_numerical': 0.006909954653422587, 'mean_word_length': 3.3533834586466167, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5330457', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1227, 'n_words': 285}