@@ -0,0 +1,3927 @@
+/*%0A * Copyright 2017, TeamDev Ltd. 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 org.spine3.server.validate;%0A%0Aimport com.google.protobuf.Descriptors.FieldDescriptor;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.spine3.base.PluralKey;%0Aimport org.spine3.base.SingularKey;%0Aimport org.spine3.test.aggregate.ProjectId;%0Aimport org.spine3.test.aggregate.Task;%0Aimport org.spine3.test.aggregate.TaskId;%0Aimport org.spine3.test.validate.msg.PatternStringFieldValue;%0Aimport org.spine3.validate.ConstraintViolationThrowable;%0Aimport org.spine3.validate.ConversionError;%0A%0Aimport java.util.List;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.spine3.base.Identifiers.newUuid;%0A%0A/**%0A * @author Illia Shepilov%0A */%0Apublic class AbstractValidatingBuilderShould %7B%0A%0A    private AbstractValidatingBuilder%3CTask%3E validatingBuilder;%0A%0A    @Before%0A    public void setUp() %7B%0A        validatingBuilder = new ConcreteValidatingBuilder();%0A    %7D%0A%0A    @Test%0A    public void return_converted_value() throws ConversionError %7B%0A        final Integer convertedValue = validatingBuilder.getConvertedValue(%0A                new SingularKey%3C%3E(Integer.class), %221%22);%0A        assertEquals(1, convertedValue.intValue());%0A    %7D%0A%0A    @Test(expected = StringifierNotFoundException.class)%0A    public void throw_exception_when_appropriate_stringifier_is_not_found() throws ConversionError %7B%0A        final String stringToConvert = %22%7Bvalue:1%7D%22;%0A        validatingBuilder.getConvertedValue(new SingularKey%3C%3E(TaskId.class), stringToConvert);%0A    %7D%0A%0A    @Test(expected = ConversionError.class)%0A    public void throw_exception_when_string_cannot_be_converted() throws ConversionError %7B%0A        final String stringToConvert = %22%22;%0A        validatingBuilder.getConvertedValue(new PluralKey%3C%3E(List.class, Integer.class),%0A                                            stringToConvert);%0A    %7D%0A%0A    @Test%0A    public void validate_value() throws ConstraintViolationThrowable %7B%0A        final FieldDescriptor descriptor = ProjectId.getDescriptor()%0A                                                    .getFields()%0A                                                    .get(0);%0A        validatingBuilder.validate(descriptor, newUuid(), %22id%22);%0A    %7D%0A%0A    @Test(expected = ConstraintViolationThrowable.class)%0A    public void throw_exception_when_field_contains_constraint_violations()%0A            throws ConstraintViolationThrowable %7B%0A        final FieldDescriptor descriptor = PatternStringFieldValue.getDescriptor()%0A                                                                  .getFields()%0A                                                                  .get(0);%0A        validatingBuilder.validate(descriptor,%0A                                   %22incorrectEmail%22,%0A                                   %22email%22);%0A    %7D%0A%0A    private static class ConcreteValidatingBuilder extends AbstractValidatingBuilder%3CTask%3E %7B%0A        @Override%0A        public Task build() %7B%0A            return Task.getDefaultInstance();%0A        %7D%0A    %7D%0A%7D%0A

Create tests for the `AbstractValidatingBuilderShould` class.