Skip to content

Commit

Permalink
#294 - Added second generic mapper test
Browse files Browse the repository at this point in the history
  • Loading branch information
starnowski committed Aug 13, 2024
1 parent 0d56a63 commit c774003
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -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 <T extends AbstractForeignKeyConfiguration<T>, M extends IConfigurationMapper<ForeignKeyConfiguration, T>, CMTC extends AbstractConfigurationMapperTestContext> extends AbstractConfigurationMapperTest<T, ForeignKeyConfiguration, M, CMTC> {

@Override
protected Class<ForeignKeyConfiguration> getConfigurationObjectClass() {
ForeignKeyConfiguration.class
}

protected abstract T createOutputInstance();

@Override
protected List<T> 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<ForeignKeyConfiguration> 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())
]
}
}
Original file line number Diff line number Diff line change
@@ -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<com.github.starnowski.posmulten.configuration.yaml.model.CustomDefinitionEntry, CustomDefinitionEntryMapper, ConfigurationMapperTestContext> {
Expand All @@ -11,11 +10,6 @@ class CustomDefinitionEntryMapperTest extends AbstractCustomDefinitionEntryMappe
new ConfigurationMapperTestContext()
}

@Override
protected Class<CustomDefinitionEntry> getConfigurationObjectClass() {
CustomDefinitionEntry.class
}

@Override
protected com.github.starnowski.posmulten.configuration.yaml.model.CustomDefinitionEntry createOutputInstance() {
new com.github.starnowski.posmulten.configuration.yaml.model.CustomDefinitionEntry()
Expand Down
Original file line number Diff line number Diff line change
@@ -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<com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration, ForeignKeyConfigurationMapper, ConfigurationMapperTestContext> {

class ForeignKeyConfigurationMapperTest extends AbstractConfigurationMapperTest<com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration, com.github.starnowski.posmulten.configuration.core.model.ForeignKeyConfiguration, ForeignKeyConfigurationMapper> {
@Override
protected ConfigurationMapperTestContext getConfigurationMapperTestContext() {
new ConfigurationMapperTestContext()
}

@Override
protected Class<ForeignKeyConfiguration> getConfigurationObjectClass() {
ForeignKeyConfiguration.class
protected com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration createOutputInstance() {
new com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration()
}

@Override
Expand All @@ -20,37 +23,4 @@ class ForeignKeyConfigurationMapperTest extends AbstractConfigurationMapperTest<
protected ForeignKeyConfigurationMapper getTestedObject() {
new ForeignKeyConfigurationMapper()
}

@Override
protected List<com.github.starnowski.posmulten.configuration.yaml.model.ForeignKeyConfiguration> 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<ForeignKeyConfiguration> 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())
]
}
}

0 comments on commit c774003

Please sign in to comment.