From 16f47d9335f8ff8124c04cf9df0fb8f8413578f2 Mon Sep 17 00:00:00 2001 From: Szymon Tarnowski <33316705+starnowski@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:59:34 +0100 Subject: [PATCH] #301 - Added implementation for builder --- ...emaContextBuilderConfigurationEnricher.java | 1 + ...textBuilderConfigurationEnricherTest.groovy | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/configuration-parent/configuration-core/src/main/java/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricher.java b/configuration-parent/configuration-core/src/main/java/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricher.java index 0bb1dc423..664e4b927 100644 --- a/configuration-parent/configuration-core/src/main/java/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricher.java +++ b/configuration-parent/configuration-core/src/main/java/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricher.java @@ -76,6 +76,7 @@ public DefaultSharedSchemaContextBuilder enrich(DefaultSharedSchemaContextBuilde if (contextConfiguration.getCurrentTenantIdentifierAsDefaultValueForTenantColumnInAllTables() != null) { builder.setCurrentTenantIdentifierAsDefaultValueForTenantColumnInAllTables(contextConfiguration.getCurrentTenantIdentifierAsDefaultValueForTenantColumnInAllTables()); } + builder.setCreateForeignKeyConstraintWithTenantColumn(contextConfiguration.getCreateForeignKeyConstraintWithTenantColumn()); validTenantValueConstraintConfigurationEnricher.enrich(builder, contextConfiguration.getValidTenantValueConstraint()); tablesEntriesEnricher.enrich(builder, contextConfiguration.getTables()); sqlDefinitionsValidationEnricher.enrich(builder, contextConfiguration.getSqlDefinitionsValidation()); diff --git a/configuration-parent/configuration-core/src/test/groovy/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricherTest.groovy b/configuration-parent/configuration-core/src/test/groovy/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricherTest.groovy index 610fec32e..1d5f5e348 100644 --- a/configuration-parent/configuration-core/src/test/groovy/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricherTest.groovy +++ b/configuration-parent/configuration-core/src/test/groovy/com/github/starnowski/posmulten/configuration/core/DefaultSharedSchemaContextBuilderConfigurationEnricherTest.groovy @@ -138,4 +138,22 @@ class DefaultSharedSchemaContextBuilderConfigurationEnricherTest extends Abstrac result == builder 1 * customDefinitionEntriesEnricher.enrich(builder, customDefinitions) } + + @Unroll + def "should set builder component with specific property createForeignKeyConstraintWithTenantColumn with value #createForeignKeyConstraintWithTenantColumn"() + { + given: + def builder = prepareBuilderMockWithZeroExpectationOfMethodsInvocation() + def configuration = new SharedSchemaContextConfiguration().setCreateForeignKeyConstraintWithTenantColumn(createForeignKeyConstraintWithTenantColumn) + + when: + def result = tested.enrich(builder, configuration) + + then: + result == builder + 1 * builder.setCreateForeignKeyConstraintWithTenantColumn(createForeignKeyConstraintWithTenantColumn) + + where: + createForeignKeyConstraintWithTenantColumn << [null, false, true] + } }