<commit_before>/*
 * Copyright 2014 <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 org.revapi.java;

import org.junit.Assert;
import org.junit.Test;

import org.revapi.java.checks.Code;

/**
 * @author <NAME>
 * @since 0.1
 */
public class ClassChecksTest extends AbstractJavaElementAnalyzerTest {

    @Test
    public void testClassVisibilityReduced() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/ClassVisibilityReduced.java", "v2/classes/ClassVisibilityReduced.java");

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_VISIBILITY_REDUCED.code()));
    }

    @Test
    public void testClassVisibilityIncreased() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v2/classes/ClassVisibilityReduced.java", "v1/classes/ClassVisibilityReduced.java");

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_VISIBILITY_INCREASED.code()));
    }

    @Test
    public void testClassAdded() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, new String[]{"v1/classes/ClassVisibilityReduced.java"},
            new String[]{"v2/classes/ClassVisibilityReduced.java", "v2/classes/ClassAdded.java"});

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_ADDED.code()));
    }

    @Test
    public void testClassRemoved() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, new String[]{"v1/classes/ClassVisibilityReduced.java", "v2/classes/ClassAdded.java"},
            new String[]{"v1/classes/ClassVisibilityReduced.java"});

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_REMOVED.code()));
    }

    @Test
    public void testNewSuperTypes() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/NewSuperTypes.java", "v2/classes/NewSuperTypes.java");
        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_INHERITS_FROM_NEW_CLASS.code()));
    }

    @Test
    public void testRemovedSuperTypes() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v2/classes/NewSuperTypes.java", "v1/classes/NewSuperTypes.java");
        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_INHERITS_FROM_CLASS.code()));
    }

    @Test
    public void testChangedSuperTypes() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/ChangedSuperTypes.java", "v2/classes/ChangedSuperTypes.java");

        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_INHERITS_FROM_CLASS.code()));
        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_INHERITS_FROM_NEW_CLASS.code()));
    }

    @Test
    public void testKindChanged() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/KindChanged.java", "v2/classes/KindChanged.java");

        Assert.assertEquals(4, (int) reporter.getProblemCounters().get(Code.CLASS_KIND_CHANGED.code()));
        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_INHERITS_FROM_NEW_CLASS.code()));
        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_INHERITS_FROM_CLASS.code()));
        Assert.assertEquals(1,
            (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_IMPLEMENTS_INTERFACE.code()));
        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NOW_IMPLEMENTS_INTERFACE.code()));
    }

    @Test
    public void testNewImplementedInterfaces() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/ImplementedInterfaces.java", "v2/classes/ImplementedInterfaces.java");

        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_IMPLEMENTS_INTERFACE.code()));
        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NOW_IMPLEMENTS_INTERFACE.code()));
    }

    @Test
    public void testRemovedImplementedInterfaces() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v2/classes/ImplementedInterfaces.java", "v1/classes/ImplementedInterfaces.java");<commit_msg>Compilation fixes in tests.<commit_after>/*
 * Copyright 2014 <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 org.revapi.java;

import org.junit.Assert;
import org.junit.Test;

import org.revapi.java.checks.Code;

/**
 * @author <NAME>
 * @since 0.1
 */
public class ClassChecksTest extends AbstractJavaElementAnalyzerTest {

    @Test
    public void testClassVisibilityReduced() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/ClassVisibilityReduced.java", "v2/classes/ClassVisibilityReduced.java");

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_VISIBILITY_REDUCED.code()));
    }

    @Test
    public void testClassVisibilityIncreased() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v2/classes/ClassVisibilityReduced.java", "v1/classes/ClassVisibilityReduced.java");

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_VISIBILITY_INCREASED.code()));
    }

    @Test
    public void testClassAdded() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, new String[]{"v1/classes/ClassVisibilityReduced.java"},
            new String[]{"v2/classes/ClassVisibilityReduced.java", "v2/classes/ClassAdded.java"});

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_ADDED.code()));
    }

    @Test
    public void testClassRemoved() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, new String[]{"v1/classes/ClassVisibilityReduced.java", "v2/classes/ClassAdded.java"},
            new String[]{"v1/classes/ClassVisibilityReduced.java"});

        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_REMOVED.code()));
    }

    @Test
    public void testNewSuperTypes() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/NewSuperTypes.java", "v2/classes/NewSuperTypes.java");
        Assert.assertEquals(1,
            (int) reporter.getProblemCounters().get(Code.CLASS_NON_FINAL_CLASS_INHERITS_FROM_NEW_CLASS.code()));
    }

    @Test
    public void testRemovedSuperTypes() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v2/classes/NewSuperTypes.java", "v1/classes/NewSuperTypes.java");
        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_INHERITS_FROM_CLASS.code()));
    }

    @Test
    public void testChangedSuperTypes() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/ChangedSuperTypes.java", "v2/classes/ChangedSuperTypes.java");

        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_INHERITS_FROM_CLASS.code()));
        Assert.assertEquals(1,
            (int) reporter.getProblemCounters().get(Code.CLASS_NON_FINAL_CLASS_INHERITS_FROM_NEW_CLASS.code()));
    }

    @Test
    public void testKindChanged() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/KindChanged.java", "v2/classes/KindChanged.java");

        Assert.assertEquals(4, (int) reporter.getProblemCounters().get(Code.CLASS_KIND_CHANGED.code()));
        Assert.assertEquals(1,
            (int) reporter.getProblemCounters().get(Code.CLASS_NON_FINAL_CLASS_INHERITS_FROM_NEW_CLASS.code()));
        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_INHERITS_FROM_CLASS.code()));
        Assert.assertEquals(1,
            (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_IMPLEMENTS_INTERFACE.code()));
        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NOW_IMPLEMENTS_INTERFACE.code()));
    }

    @Test
    public void testNewImplementedInterfaces() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v1/classes/ImplementedInterfaces.java", "v2/classes/ImplementedInterfaces.java");

        Assert
            .assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NO_LONGER_IMPLEMENTS_INTERFACE.code()));
        Assert.assertEquals(1, (int) reporter.getProblemCounters().get(Code.CLASS_NOW_IMPLEMENTS_INTERFACE.code()));
    }

    @Test
    public void testRemovedImplementedInterfaces() throws Exception {
        ProblemOccurrenceReporter reporter = new ProblemOccurrenceReporter();
        runAnalysis(reporter, "v2/classes/ImplementedInterfaces.java", "v1/classes/ImplementedInterfaces.java");
{'fraction_non_alphanumeric': 0.10928308823529412, 'fraction_numerical': 0.008639705882352942, 'mean_word_length': 4.22873618452667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5562413', 'n_tokens_mistral': 3135, 'n_tokens_neox': 3039, 'n_words': 570}