@@ -0,0 +1,3362 @@
+/*%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 io.spine.server.storage.jdbc.type;%0A%0Aimport io.spine.core.Version;%0Aimport io.spine.server.entity.storage.Column;%0Aimport io.spine.server.entity.storage.ColumnTypeRegistry;%0Aimport io.spine.server.storage.jdbc.Sql;%0Aimport org.junit.Test;%0A%0Aimport java.sql.PreparedStatement;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * @author Dmytro Dashenkov%0A */%0Apublic class JdbcTypeRegistryFactoryShould %7B%0A%0A    @Test%0A    public void provide_default_type_registry_for_required_types() %7B%0A        final ColumnTypeRegistry%3C?%3E registry = JdbcTypeRegistryFactory.defaultInstance();%0A        assertNotNull(registry);%0A        assertNotNull(registry.get(columnWithType(Version.class)));%0A        assertNotNull(registry.get(columnWithType(boolean.class)));%0A    %7D%0A%0A    @Test%0A    public void provide_builder_for_extending_defaults() %7B%0A        final ColumnTypeRegistry%3C?%3E registry =%0A                JdbcTypeRegistryFactory.predefinedValuesAnd()%0A                                       .put(String.class, CustomType.INSTANCE)%0A                                       .build();%0A        assertNotNull(registry);%0A        assertNotNull(registry.get(columnWithType(Version.class)));%0A        assertNotNull(registry.get(columnWithType(boolean.class)));%0A        assertEquals(registry.get(columnWithType(String.class)),%0A                     CustomType.INSTANCE);%0A    %7D%0A%0A    private static Column columnWithType(Class%3C?%3E cls) %7B%0A        final Column column = mock(Column.class);%0A        when(column.getType()).thenReturn(cls);%0A        return column;%0A    %7D%0A%0A    private enum CustomType implements JdbcColumnType%3CString, String%3E %7B%0A%0A        INSTANCE;%0A%0A        @Override%0A        public Sql.Type getSqlType() %7B%0A            return Sql.Type.VARCHAR_255;%0A        %7D%0A%0A        @Override%0A        public String convertColumnValue(String fieldValue) %7B%0A            return fieldValue;%0A        %7D%0A%0A        @Override%0A        public void setColumnValue(PreparedStatement storageRecord, String value,%0A                                   Integer columnIdentifier) %7B%0A            // NoOp (as for tests)%0A        %7D%0A%0A        @Override%0A        public void setNull(PreparedStatement storageRecord, Integer columnIdentifier) %7B%0A            // NoOp (as for tests)%0A        %7D%0A    %7D%0A%7D%0A

Add tests for JdbcTypeRegistryFactory.