@@ -0,0 +1,3350 @@
+/*%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.validate.diags;%0A%0Aimport com.google.common.collect.ImmutableList;%0Aimport com.google.common.testing.NullPointerTester;%0Aimport com.google.common.truth.StringSubject;%0Aimport com.google.protobuf.Timestamp;%0Aimport io.spine.base.FieldPath;%0Aimport io.spine.base.FieldPaths;%0Aimport io.spine.type.TypeName;%0Aimport io.spine.validate.ConstraintViolation;%0Aimport org.junit.jupiter.api.DisplayName;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport static com.google.common.truth.Truth.assertThat;%0A%0A@DisplayName(%22ViolationText should%22)%0Aclass ViolationTextTest %7B%0A%0A    @Test%0A    @DisplayName(%22not accept null violations%22)%0A    void nullTolerance() %7B%0A        new NullPointerTester()%0A                .testAllPublicStaticMethods(ViolationText.class);%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22include type info in the violation text%22)%0A    void includeType() %7B%0A        TypeName type = TypeName.of(Timestamp.class);%0A        ConstraintViolation violation = ConstraintViolation%0A                .newBuilder()%0A                .setTypeName(type.value())%0A                .build();%0A        ViolationText text = ViolationText.of(violation);%0A        assertThat(text.toString()).contains(type.value());%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22include field info in the violation text%22)%0A    void includeField() %7B%0A        FieldPath field = FieldPaths.parse(%22msg.foo.bar%22);%0A        ConstraintViolation violation = ConstraintViolation%0A                .newBuilder()%0A                .setFieldPath(field)%0A                .build();%0A        ViolationText text = ViolationText.of(violation);%0A        assertThat(text.toString()).contains(FieldPaths.toString(field));%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22compile tests for many violations into one%22)%0A    void compileManyTexts() %7B%0A        ConstraintViolation first = ConstraintViolation%0A                .newBuilder()%0A                .setMsgFormat(%22Errored with a message%22)%0A                .build();%0A        ConstraintViolation second = ConstraintViolation%0A                .newBuilder()%0A                .setMsgFormat(%22Messaged with an error%22)%0A                .build();%0A        String text = ViolationText.ofAll(ImmutableList.of(first, second));%0A        StringSubject assertText = assertThat(text);%0A        assertText.contains(ViolationText.of(first).toString());%0A        assertText.contains(ViolationText.of(second).toString());%0A    %7D%0A%7D%0A

Add a test for ViolationText.