maksaska commented on code in PR #317: URL: https://github.com/apache/ignite-extensions/pull/317#discussion_r2273789252
########## modules/cdc-ext/src/test/java/org/apache/ignite/cdc/postgresql/JavaToSqlTypeMapperTest.java: ########## @@ -0,0 +1,438 @@ +package org.apache.ignite.cdc.postgresql; + +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import io.zonky.test.db.postgres.embedded.EmbeddedPostgres; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cluster.ClusterState; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.junit.Test; + +import static org.apache.ignite.cdc.postgresql.JavaToSqlTypeMapperTest.NumericMeta.NO_NUMERIC_META; +import static org.apache.ignite.cdc.postgresql.JavaToSqlTypeMapperTest.NumericMeta.PRECISION_AND_SCALE; +import static org.apache.ignite.cdc.postgresql.JavaToSqlTypeMapperTest.NumericMeta.PRECISION_ONLY; +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; + +/** */ +public class JavaToSqlTypeMapperTest extends CdcPostgreSqlReplicationAbstractTest { + /** */ + private final JavaToSqlTypeMapper javaToSqlTypeMapper = new JavaToSqlTypeMapper(); + + /** */ + private IgniteEx src; + + /** */ + private EmbeddedPostgres postgres; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + DataRegionConfiguration dataRegionConfiguration = new DataRegionConfiguration() + .setPersistenceEnabled(true) + .setCdcEnabled(true); + + DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration() + .setWalForceArchiveTimeout(5_000) + .setDefaultDataRegionConfiguration(dataRegionConfiguration); + + cfg.setDataStorageConfiguration(dataStorageConfiguration); + cfg.setConsistentId(igniteInstanceName); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected IgniteToPostgreSqlCdcConsumer getCdcConsumerConfiguration() { + IgniteToPostgreSqlCdcConsumer cdcCfg = super.getCdcConsumerConfiguration(); + + cdcCfg.setCreateTables(true); + + return cdcCfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + + src = startGrid(0); + + src.cluster().state(ClusterState.ACTIVE); + + postgres = EmbeddedPostgres.builder().start(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + postgres.close(); + + cleanPersistenceDir(); + } + + /** */ + @Test + public void javaToPostgreSqlTypesMappingTest() throws Exception { + Set<String> cachesToReplicate = Arrays.stream(JavaToSqlTypeMapper.JavaToSqlType.values()) + .map(JavaToSqlTypeMapper.JavaToSqlType::javaTypeName) + .filter(name -> !name.equals(Object.class.getName())) + .map(clsName -> clsName.replace('.', '_').replace('[', '_')) + .flatMap(clsName -> Stream.of( + clsName, + clsName + "_WithPrecision", + clsName + "_WithPrecision_WithScale" + )) + .collect(Collectors.toSet()); + + IgniteInternalFuture<?> fut = startIgniteToPostgreSqlCdcConsumer( + src.configuration(), + cachesToReplicate, + postgres.getPostgresDatabase() + ); + + createCache("string", null, null); + createCache("string", 10, null); + createCache("string", 10, 10); + + createCache(5, null, null); Review Comment: Yep. I refactored this part ########## modules/cdc-ext/src/test/java/org/apache/ignite/cdc/postgresql/JavaToSqlTypeMapperTest.java: ########## @@ -0,0 +1,438 @@ +package org.apache.ignite.cdc.postgresql; + +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import io.zonky.test.db.postgres.embedded.EmbeddedPostgres; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cluster.ClusterState; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.junit.Test; + +import static org.apache.ignite.cdc.postgresql.JavaToSqlTypeMapperTest.NumericMeta.NO_NUMERIC_META; +import static org.apache.ignite.cdc.postgresql.JavaToSqlTypeMapperTest.NumericMeta.PRECISION_AND_SCALE; +import static org.apache.ignite.cdc.postgresql.JavaToSqlTypeMapperTest.NumericMeta.PRECISION_ONLY; +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; + +/** */ +public class JavaToSqlTypeMapperTest extends CdcPostgreSqlReplicationAbstractTest { + /** */ + private final JavaToSqlTypeMapper javaToSqlTypeMapper = new JavaToSqlTypeMapper(); + + /** */ + private IgniteEx src; + + /** */ + private EmbeddedPostgres postgres; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + DataRegionConfiguration dataRegionConfiguration = new DataRegionConfiguration() + .setPersistenceEnabled(true) + .setCdcEnabled(true); + + DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration() + .setWalForceArchiveTimeout(5_000) + .setDefaultDataRegionConfiguration(dataRegionConfiguration); + + cfg.setDataStorageConfiguration(dataStorageConfiguration); + cfg.setConsistentId(igniteInstanceName); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected IgniteToPostgreSqlCdcConsumer getCdcConsumerConfiguration() { + IgniteToPostgreSqlCdcConsumer cdcCfg = super.getCdcConsumerConfiguration(); + + cdcCfg.setCreateTables(true); + + return cdcCfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + + src = startGrid(0); + + src.cluster().state(ClusterState.ACTIVE); + + postgres = EmbeddedPostgres.builder().start(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + postgres.close(); + + cleanPersistenceDir(); + } + + /** */ + @Test + public void javaToPostgreSqlTypesMappingTest() throws Exception { + Set<String> cachesToReplicate = Arrays.stream(JavaToSqlTypeMapper.JavaToSqlType.values()) + .map(JavaToSqlTypeMapper.JavaToSqlType::javaTypeName) + .filter(name -> !name.equals(Object.class.getName())) + .map(clsName -> clsName.replace('.', '_').replace('[', '_')) + .flatMap(clsName -> Stream.of( + clsName, + clsName + "_WithPrecision", + clsName + "_WithPrecision_WithScale" + )) + .collect(Collectors.toSet()); + + IgniteInternalFuture<?> fut = startIgniteToPostgreSqlCdcConsumer( + src.configuration(), + cachesToReplicate, + postgres.getPostgresDatabase() + ); + + createCache("string", null, null); Review Comment: Fixed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org