/*
 * Copyright 2019, 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.protoc;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

@DisplayName("FilePatterns should")
final class FilePatternsTest {

    @DisplayName("not allow null values for")
    @Nested
    final class NotAllowNulls {

        @DisplayName("filePostfix pattern")
        @Test
        void filePostfix() {
            Assertions.assertThrows(NullPointerException.class, () -> {
                //noinspection ConstantConditions,ResultOfMethodCallIgnored
                FilePatterns.filePostfix(null);
            });
        }

        @DisplayName("filePrefix pattern")
        @Test
        void filePrefix() {
            Assertions.assertThrows(NullPointerException.class, () -> {
                //noinspection ConstantConditions,ResultOfMethodCallIgnored
                FilePatterns.filePrefix(null);
            });
        }

        @DisplayName("regex pattern")
        @Test
        void regex() {
            Assertions.assertThrows(NullPointerException.class, () -> {
                //noinspection ConstantConditions,ResultOfMethodCallIgnored
                FilePatterns.fileRegex(null);
            });
        }
    }

    @DisplayName("create a valid")
    @Nested
    final class CreateValid {

        @DisplayName("file_postfix pattern")
        @Test
        void filePostfix() {
            String postfix = "documents.proto";
            FilePattern filter = FilePatterns.filePostfix(postfix);
            assertEquals(postfix, filter.getFilePostfix());
        }

        @DisplayName("file_prefix pattern")
        @Test
        void filePrefix() {
            String prefix = "documents_";
            FilePattern pattern = FilePatterns.filePrefix(prefix);
            assertEquals(prefix, pattern.getFilePrefix());
        }

        @DisplayName("regex pattern")
        @Test
        void regex() {
            String regex = ".*documents.*";
            FilePattern pattern = FilePatterns.fileRegex(regex);
            assertEquals(regex, pattern.getRegex());
        }
    }
}

@@ -1717,32 +1717,111 @@
  %7D);%0A        %7D%0A%0A
+        @SuppressWarnings(%7B%22ResultOfMethodCallIgnored%22, %22ConstantConditions%22%7D)%0A
         @Display
@@ -1981,141 +1981,144 @@
     
-//noinspection ConstantConditions,ResultOfMethodCallIgnored%0A                FilePatterns.filePrefix(null);%0A            %7D);%0A        %7D%0A
+FilePatterns.filePrefix(null);%0A            %7D);%0A        %7D%0A%0A        @SuppressWarnings(%7B%22ResultOfMethodCallIgnored%22, %22ConstantConditions%22%7D)
 %0A   
@@ -2265,84 +2265,8 @@
 %3E %7B%0A
-                //noinspection ConstantConditions,ResultOfMethodCallIgnored%0A
     
@@ -2725,361 +2725,1280 @@
 le_p
-refix pattern%22)%0A        @Test%0A        void filePrefix() %7B%0A            String prefix = %22documents_%22;%0A            FilePattern pattern = FilePatterns.filePrefix(prefix);%0A            assertEquals(prefix, pattern.getFilePrefix());%0A        %7D%0A%0A        @DisplayName(%22regex pattern%22)%0A        @Test%0A        void regex() %7B%0A            String regex = %22.*documents.*
+ostfix pattern with path parts%22)%0A        @Test%0A        void filePostfixWithPathParts()%7B%0A            String postfix = %22tools/protoc/documents.proto%22;%0A            FilePattern filter = FilePatterns.filePostfix(postfix);%0A            assertEquals(postfix, filter.getFilePostfix());%0A        %7D%0A%0A        @DisplayName(%22file_prefix pattern%22)%0A        @Test%0A        void filePrefix() %7B%0A            String prefix = %22documents_%22;%0A            FilePattern pattern = FilePatterns.filePrefix(prefix);%0A            assertEquals(prefix, pattern.getFilePrefix());%0A        %7D%0A%0A        @DisplayName(%22file_prefix pattern with path parts%22)%0A        @Test%0A        void filePrefixWithPathParts()%7B%0A            String prefix = %22io/spine/tools/documents_%22;%0A            FilePattern pattern = FilePatterns.filePrefix(prefix);%0A            assertEquals(prefix, pattern.getFilePrefix());%0A        %7D%0A%0A        @DisplayName(%22regex pattern%22)%0A        @Test%0A        void regex() %7B%0A            String regex = %22.*documents.*%22;%0A            FilePattern pattern = FilePatterns.fileRegex(regex);%0A            assertEquals(regex, pattern.getRegex());%0A        %7D%0A%0A        @DisplayName(%22regex pattern with path parts%22)%0A        @Test%0A        void regexWithPathParts()%7B%0A            String regex = %22io/spine/.*/documents/.*%5C%5C.proto
 %22;%0A 

Add examples of file patterns with path parts included