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 00000000..73c537e6 --- /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 b3df2c4c..84fed23c 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 983afe8f..98add4a1 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()) - ] - } }