<commit_before>/*
 * Copyright 2009-2010, 2012-2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.jqno.equalsverifier.integration.extended_contract;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import nl.jqno.equalsverifier.testhelpers.IntegrationTestBase;
import nl.jqno.equalsverifier.testhelpers.types.Color;
import nl.jqno.equalsverifier.testhelpers.types.FinalPoint;
import nl.jqno.equalsverifier.testhelpers.types.Point;
import org.junit.Test;

import java.util.Objects;

import static nl.jqno.equalsverifier.testhelpers.Util.defaultHashCode;

public class SignificantFieldsTest extends IntegrationTestBase {
    @Test
    public void fail_whenEqualsUsesAFieldAndHashCodeDoesnt() {
        expectFailure("Significant fields", "equals relies on", "yNotUsed", "but hashCode does not");
        EqualsVerifier.forClass(ExtraFieldInEquals.class)
                .verify();
    }

    @Test
    public void fail_whenHashCodeUsesAFieldAndEqualsDoesnt() {
        expectFailure("Significant fields", "hashCode relies on", "yNotUsed", "but equals does not");
        EqualsVerifier.forClass(ExtraFieldInHashCode.class)
                .verify();
    }

    @Test
    public void succeed_whenAllFieldsAreUsed_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(FinalPoint.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void succeed_whenAFieldIsUnused_givenAllFieldsWarningIsSuppressed() {
        EqualsVerifier.forClass(OneFieldUnused.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void fail_whenAFieldIsUnused() {
        expectFailure("Significant fields", "equals does not use", "colorNotUsed");
        EqualsVerifier.forClass(OneFieldUnused.class)
                .verify();
    }

    @Test
    public void succeed_whenATransientFieldIsUnused_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(OneTransientFieldUnusedColorPoint.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void succeed_whenAStaticFieldIsUnused_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(OneStaticFieldUnusedColorPoint.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void succeed_whenAFieldIsUnusedInASubclass_givenAllFieldsWarningIsSuppressed() {
        EqualsVerifier.forClass(OneFieldUnusedExtended.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void fail_whenAFieldIsUnusedInASubclass() {
        expectFailure("Significant fields", "equals does not use", "colorNotUsed");
        EqualsVerifier.forClass(OneFieldUnusedExtended.class)
                .verify();
    }

    @Test
    public void succeed_whenNoEqualsMethodPresent_givenAllFieldsWarningIsSuppressed() {
        EqualsVerifier.forClass(NoFieldsUsed.class)
                .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void succeed_whenNoFieldsAreAdded_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(NoFieldsAdded.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void fail_whenNoFieldsAreUsed() {
        expectFailure("Significant fields", "equals does not use", "color");<commit_msg>Fix tests that suppressed all fields warning but shouldn't<commit_after>/*
 * Copyright 2009-2010, 2012-2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.jqno.equalsverifier.integration.extended_contract;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import nl.jqno.equalsverifier.testhelpers.IntegrationTestBase;
import nl.jqno.equalsverifier.testhelpers.types.Color;
import nl.jqno.equalsverifier.testhelpers.types.FinalPoint;
import nl.jqno.equalsverifier.testhelpers.types.Point;
import org.junit.Test;

import java.util.Objects;

import static nl.jqno.equalsverifier.testhelpers.Util.defaultHashCode;

public class SignificantFieldsTest extends IntegrationTestBase {
    @Test
    public void fail_whenEqualsUsesAFieldAndHashCodeDoesnt() {
        expectFailure("Significant fields", "equals relies on", "yNotUsed", "but hashCode does not");
        EqualsVerifier.forClass(ExtraFieldInEquals.class)
                .verify();
    }

    @Test
    public void fail_whenHashCodeUsesAFieldAndEqualsDoesnt() {
        expectFailure("Significant fields", "hashCode relies on", "yNotUsed", "but equals does not");
        EqualsVerifier.forClass(ExtraFieldInHashCode.class)
                .verify();
    }

    @Test
    public void succeed_whenAllFieldsAreUsed_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(FinalPoint.class)
                .verify();
    }

    @Test
    public void succeed_whenAFieldIsUnused_givenAllFieldsWarningIsSuppressed() {
        EqualsVerifier.forClass(OneFieldUnused.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void fail_whenAFieldIsUnused() {
        expectFailure("Significant fields", "equals does not use", "colorNotUsed");
        EqualsVerifier.forClass(OneFieldUnused.class)
                .verify();
    }

    @Test
    public void succeed_whenATransientFieldIsUnused_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(OneTransientFieldUnusedColorPoint.class)
                .verify();
    }

    @Test
    public void succeed_whenAStaticFieldIsUnused_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(OneStaticFieldUnusedColorPoint.class)
                .verify();
    }

    @Test
    public void succeed_whenAFieldIsUnusedInASubclass_givenAllFieldsWarningIsSuppressed() {
        EqualsVerifier.forClass(OneFieldUnusedExtended.class)
                .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void fail_whenAFieldIsUnusedInASubclass() {
        expectFailure("Significant fields", "equals does not use", "colorNotUsed");
        EqualsVerifier.forClass(OneFieldUnusedExtended.class)
                .verify();
    }

    @Test
    public void succeed_whenNoEqualsMethodPresent_givenAllFieldsWarningIsSuppressed() {
        EqualsVerifier.forClass(NoFieldsUsed.class)
                .suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.ALL_FIELDS_SHOULD_BE_USED)
                .verify();
    }

    @Test
    public void succeed_whenNoFieldsAreAdded_givenAllFieldsShouldBeUsed() {
        EqualsVerifier.forClass(NoFieldsAdded.class)
                .verify();
    }

    @Test
    public void fail_whenNoFieldsAreUsed() {
        expectFailure("Significant fields", "equals does not use", "color");
{'fraction_non_alphanumeric': 0.08201223317937835, 'fraction_numerical': 0.004993134440144801, 'mean_word_length': 3.3425474254742547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1469245', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2253, 'n_words': 459}