/*
 * Copyright 2018, TeamDev. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package io.spine.tools.check.vbuilder;

import com.google.common.base.Predicates;
import com.google.errorprone.CompilationTestHelper;
import org.junit.Before;
import org.junit.Test;

import java.util.function.Predicate;

public class UseValidatingBuilderShould {

    private CompilationTestHelper compilationTestHelper;

    @Before
    public void setUp() {
        compilationTestHelper =
                CompilationTestHelper.newInstance(UseValidatingBuilder.class, getClass());
    }

    @Test
    public void recognize_positive_cases() {
        Predicate<CharSequence> predicate =
                Predicates.containsPattern(UseValidatingBuilder.SUMMARY)::apply;
        compilationTestHelper.expectErrorMessage("UseValidatingBuilderError", predicate::test);
        compilationTestHelper.addSourceFile("UseValidatingBuilderPositives.java")
                             .doTest();
    }

    @Test
    public void recognize_negative_cases() {
        compilationTestHelper.addSourceFile("UseValidatingBuilderNegatives.java")
                             .doTest();
    }
}

@@ -1227,16 +1227,1001 @@
 icate;%0A%0A
+/**%0A * This test requires configuring %22-Xbootclasspath...%22 option with the path to the %7B@code%0A * com.google.errorprone.javac%7D jar.%0A *%0A * %3Cp%3EIn Gradle it's done automatically via the separate task (see the %7B@code build.gradle%7D of this%0A * module).%0A *%0A * %3Cp%3ETo run the test in Idea you need to add VM options manually in the %22Edit configurations%22 tab.%0A * Typically, the %7B@code javac%7D jar can be found in the Gradle Caches directory in the%0A * %22modules-2/files-2.1/com.google.errorprone/javac/%22 folder or its subfolders.%0A *%0A * %3Cp%3EAfter you acquired the path to the existing %7B@code javac%7D jar, add the following VM Option:%0A * %3Cpre%3E%0A *  -Xbootclasspath/p:%60javacPath%60%0A * %3C/pre%3E%0A * where the %60javacPath%60 is the path to your %7B@code javac%7D jar.%0A *%0A * %3Cp%3EFor the information about how this test suite works, see the Error Prone%0A * %3Ca href=%22https://github.com/google/error-prone/wiki/Writing-a-check#testing-a-bugchecker%22%3E%0A * guide%3C/a%3E to testing the custom checks.%0A *%0A * @author Dmytro Kuzmin%0A */%0A
 public c

Add description to the test