From c7740033d5495a708fbe735080a35f59d727b885 Mon Sep 17 00:00:00 2001 From: Szymon Tarnowski <33316705+starnowski@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:33:23 +0200 Subject: [PATCH] #294 - Added second generic mapper test --- ...ctForeignKeyConfigurationMapperTest.groovy | 50 +++++++++++++++++++ .../CustomDefinitionEntryMapperTest.groovy | 6 --- .../ForeignKeyConfigurationMapperTest.groovy | 46 +++-------------- 3 files changed, 58 insertions(+), 44 deletions(-) create mode 100644 configuration-parent/configuration-yaml-interpreter-parent/common-tests/src/main/groovy/com/github/starnowski/posmulten/configuration/common/yaml/mappers/AbstractForeignKeyConfigurationMapperTest.groovy diff --git a/configuration-parent/configuration-yaml-interpreter-parent/common-tests/src/main/groovy/com/github/starnowski/posmulten/configuration/common/yaml/mappers/AbstractForeignKeyConfigurationMapperTest.groovy b/configuration-parent/configuration-yaml-interpreter-parent/common-tests/src/main/groovy/com/github/starnowski/posmulten/configuration/common/yaml/mappers/AbstractForeignKeyConfigurationMapperTest.groovy new file mode 100644 index 000000000..73c537e67 --- /dev/null +++ b/configuration-parent/configuration-yaml-interpreter-parent/common-tests/src/main/groovy/com/github/starnowski/posmulten/configuration/common/yaml/mappers/AbstractForeignKeyConfigurationMapperTest.groovy @@ -0,0 +1,50 @@ +package com.github.starnowski.posmulten.configuration.common.yaml.mappers + +import com.github.starnowski.posmulten.configuration.core.model.ForeignKeyConfiguration +import com.github.starnowski.posmulten.configuration.yaml.core.IConfigurationMapper +import com.github.starnowski.posmulten.configuration.yaml.core.model.AbstractForeignKeyConfiguration + +import static com.github.starnowski.posmulten.postgresql.test.utils.MapBuilder.mapBuilder + +abstract class AbstractForeignKeyConfigurationMapperTest , M extends IConfigurationMapper, CMTC extends AbstractConfigurationMapperTestContext> extends AbstractConfigurationMapperTest { + + @Override + protected Class getConfigurationObjectClass() { + ForeignKeyConfiguration.class + } + + protected abstract T createOutputInstance(); + + @Override + protected List prepareExpectedMappedObjectsList() { + [ + createOutputInstance(), + createOutputInstance(), + createOutputInstance().setConstraintName("asfxzvz") + .setTableName("ccc"), + createOutputInstance().setConstraintName("fk_constraint") + .setTableName("some_table") + .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("user_id", "id").build()), + createOutputInstance().setConstraintName("users_fk") + .setTableName("users_po_table") + .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("sss", "uuid").put("some_id", "primary_key_col_id").build()) + ] + } + + @Override + protected List prepareExpectedUnmappeddObjectsList() { + [ + new ForeignKeyConfiguration(), + new ForeignKeyConfiguration().setConstraintName(null) + .setTableName(null), + new ForeignKeyConfiguration().setConstraintName("asfxzvz") + .setTableName("ccc"), + new ForeignKeyConfiguration().setConstraintName("fk_constraint") + .setTableName("some_table") + .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("user_id", "id").build()), + new ForeignKeyConfiguration().setConstraintName("users_fk") + .setTableName("users_po_table") + .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("sss", "uuid").put("some_id", "primary_key_col_id").build()) + ] + } +} diff --git a/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/CustomDefinitionEntryMapperTest.groovy b/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/CustomDefinitionEntryMapperTest.groovy index b3df2c4c0..84fed23cf 100644 --- a/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/CustomDefinitionEntryMapperTest.groovy +++ b/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/CustomDefinitionEntryMapperTest.groovy @@ -1,7 +1,6 @@ package com.github.starnowski.posmulten.configuration.yaml.mappers import com.github.starnowski.posmulten.configuration.common.yaml.mappers.AbstractCustomDefinitionEntryMapperTest -import com.github.starnowski.posmulten.configuration.core.model.CustomDefinitionEntry class CustomDefinitionEntryMapperTest extends AbstractCustomDefinitionEntryMapperTest { @@ -11,11 +10,6 @@ class CustomDefinitionEntryMapperTest extends AbstractCustomDefinitionEntryMappe new ConfigurationMapperTestContext() } - @Override - protected Class getConfigurationObjectClass() { - CustomDefinitionEntry.class - } - @Override protected com.github.starnowski.posmulten.configuration.yaml.model.CustomDefinitionEntry createOutputInstance() { new com.github.starnowski.posmulten.configuration.yaml.model.CustomDefinitionEntry() diff --git a/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/ForeignKeyConfigurationMapperTest.groovy b/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/ForeignKeyConfigurationMapperTest.groovy index 983afe8f8..98add4a11 100644 --- a/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/ForeignKeyConfigurationMapperTest.groovy +++ b/configuration-parent/configuration-yaml-interpreter-parent/configuration-yaml-interpreter/src/test/groovy/com/github/starnowski/posmulten/configuration/yaml/mappers/ForeignKeyConfigurationMapperTest.groovy @@ -1,14 +1,17 @@ package com.github.starnowski.posmulten.configuration.yaml.mappers -import com.github.starnowski.posmulten.configuration.core.model.ForeignKeyConfiguration +import com.github.starnowski.posmulten.configuration.common.yaml.mappers.AbstractForeignKeyConfigurationMapperTest -import static com.github.starnowski.posmulten.postgresql.test.utils.MapBuilder.mapBuilder +class ForeignKeyConfigurationMapperTest extends AbstractForeignKeyConfigurationMapperTest { -class ForeignKeyConfigurationMapperTest extends AbstractConfigurationMapperTest { + @Override + protected ConfigurationMapperTestContext getConfigurationMapperTestContext() { + new ConfigurationMapperTestContext() + } @Override - protected Class getConfigurationObjectClass() { - ForeignKeyConfiguration.class + protected com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration createOutputInstance() { + new com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration() } @Override @@ -20,37 +23,4 @@ class ForeignKeyConfigurationMapperTest extends AbstractConfigurationMapperTest< protected ForeignKeyConfigurationMapper getTestedObject() { new ForeignKeyConfigurationMapper() } - - @Override - protected List prepareExpectedMappedObjectsList() { - [ - new com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration(), - new com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration(), - new com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration().setConstraintName("asfxzvz") - .setTableName("ccc"), - new com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration().setConstraintName("fk_constraint") - .setTableName("some_table") - .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("user_id", "id").build()), - new com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration().setConstraintName("users_fk") - .setTableName("users_po_table") - .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("sss", "uuid").put("some_id", "primary_key_col_id").build()) - ] - } - - @Override - protected List prepareExpectedUnmappeddObjectsList() { - [ - new ForeignKeyConfiguration(), - new ForeignKeyConfiguration().setConstraintName(null) - .setTableName(null), - new ForeignKeyConfiguration().setConstraintName("asfxzvz") - .setTableName("ccc"), - new ForeignKeyConfiguration().setConstraintName("fk_constraint") - .setTableName("some_table") - .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("user_id", "id").build()), - new ForeignKeyConfiguration().setConstraintName("users_fk") - .setTableName("users_po_table") - .setForeignKeyPrimaryKeyColumnsMappings(mapBuilder().put("sss", "uuid").put("some_id", "primary_key_col_id").build()) - ] - } }