@@ -0,0 +1,3016 @@
+/*%0A * Copyright 2019, TeamDev. All rights reserved.%0A *%0A * Redistribution and use in source and/or binary forms, with or without%0A * modification, must retain the above copyright notice and the following%0A * disclaimer.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0A%0Apackage io.spine.tools.validate;%0A%0Aimport com.google.common.collect.ImmutableList;%0Aimport com.google.common.testing.NullPointerTester;%0Aimport com.google.errorprone.annotations.Immutable;%0Aimport com.google.protobuf.Empty;%0Aimport io.spine.code.proto.FieldContext;%0Aimport io.spine.type.MessageType;%0Aimport io.spine.validate.ConstraintViolation;%0Aimport io.spine.validate.CustomConstraint;%0Aimport io.spine.validate.MessageValue;%0Aimport org.junit.jupiter.api.DisplayName;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport static com.google.common.testing.NullPointerTester.Visibility.PACKAGE;%0Aimport static io.spine.testing.DisplayNames.NOT_ACCEPT_NULLS;%0Aimport static org.junit.jupiter.api.Assertions.assertThrows;%0A%0A@DisplayName(%22%60ConstraintCompiler%60 should%22)%0Aclass ConstraintCompilerTest %7B%0A%0A    @Test%0A    @DisplayName(NOT_ACCEPT_NULLS)%0A    void notNull() %7B%0A        new NullPointerTester()%0A                .setDefault(MessageType.class, FakeConstraint.INSTANCE.targetType())%0A                .setDefault(String.class, %22nonEmptyString%22)%0A                .testConstructors(ConstraintCompiler.class, PACKAGE);%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22throw %60UnsupportedOperationException%60 upon %60CustomConstraint%60%22)%0A    void notAllowCustom() %7B%0A        CustomConstraint constraint = FakeConstraint.INSTANCE;%0A        ConstraintCompiler compiler =%0A                new ConstraintCompiler(%22test%22, constraint.targetType());%0A        assertThrows(UnsupportedOperationException.class, () -%3E compiler.visitCustom(constraint));%0A    %7D%0A%0A    @Immutable%0A    private enum FakeConstraint implements CustomConstraint %7B%0A%0A        INSTANCE;%0A%0A        @Override%0A        public ImmutableList%3CConstraintViolation%3E validate(MessageValue containingMessage) %7B%0A            return ImmutableList.of();%0A        %7D%0A%0A        @Override%0A        public MessageType targetType() %7B%0A            return new MessageType(Empty.getDescriptor());%0A        %7D%0A%0A        @Override%0A        public String errorMessage(FieldContext field) %7B%0A            return %22%22;%0A        %7D%0A    %7D%0A%7D%0A

Add tests for `ConstraintCompiler`