From 6a507ce9fe75d0b2af59e29c1798e06f2a22416a Mon Sep 17 00:00:00 2001 From: clean-coder Date: Wed, 10 Jul 2024 09:05:46 +0200 Subject: [PATCH] #921: remove (unused) SchemaMultiTenantConnectionProvider(s) for h2/pgsql (SchemaMultiTenantConnectionProvider is no longer abstract) --- ...vider.java => SchemaMultiTenantConnectionProvider.java} | 6 +++--- .../SchemaMultiTenantConnectionProviderH2.java | 4 ---- .../SchemaMultiTenantConnectionProviderPGSQL.java | 4 ---- .../main/resources/application-integration-test.properties | 2 -- backend/src/main/resources/application.properties | 2 +- .../SchemaMultiTenantConnectionProviderInternalsTest.java | 2 +- .../SchemaMultiTenantConnectionProviderTest.java | 7 ++----- 7 files changed, 7 insertions(+), 20 deletions(-) rename backend/src/main/java/ch/puzzle/okr/multitenancy/{AbstractSchemaMultiTenantConnectionProvider.java => SchemaMultiTenantConnectionProvider.java} (95%) delete mode 100644 backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderH2.java delete mode 100644 backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderPGSQL.java diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/AbstractSchemaMultiTenantConnectionProvider.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProvider.java similarity index 95% rename from backend/src/main/java/ch/puzzle/okr/multitenancy/AbstractSchemaMultiTenantConnectionProvider.java rename to backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProvider.java index dbc41f1a9e..cfc6da1e6e 100644 --- a/backend/src/main/java/ch/puzzle/okr/multitenancy/AbstractSchemaMultiTenantConnectionProvider.java +++ b/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProvider.java @@ -16,13 +16,13 @@ import static ch.puzzle.okr.multitenancy.TenantContext.DEFAULT_TENANT_ID; -public class AbstractSchemaMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider { +public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider { - private static final Logger logger = LoggerFactory.getLogger(AbstractSchemaMultiTenantConnectionProvider.class); + private static final Logger logger = LoggerFactory.getLogger(SchemaMultiTenantConnectionProvider.class); final Map connectionProviderMap; - public AbstractSchemaMultiTenantConnectionProvider() { + public SchemaMultiTenantConnectionProvider() { this.connectionProviderMap = new HashMap<>(); } diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderH2.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderH2.java deleted file mode 100644 index fdb3f35599..0000000000 --- a/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderH2.java +++ /dev/null @@ -1,4 +0,0 @@ -package ch.puzzle.okr.multitenancy; - -public class SchemaMultiTenantConnectionProviderH2 extends AbstractSchemaMultiTenantConnectionProvider { -} \ No newline at end of file diff --git a/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderPGSQL.java b/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderPGSQL.java deleted file mode 100644 index 3abef4ed97..0000000000 --- a/backend/src/main/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderPGSQL.java +++ /dev/null @@ -1,4 +0,0 @@ -package ch.puzzle.okr.multitenancy; - -public class SchemaMultiTenantConnectionProviderPGSQL extends AbstractSchemaMultiTenantConnectionProvider { -} \ No newline at end of file diff --git a/backend/src/main/resources/application-integration-test.properties b/backend/src/main/resources/application-integration-test.properties index 1111887186..c19428abf1 100644 --- a/backend/src/main/resources/application-integration-test.properties +++ b/backend/src/main/resources/application-integration-test.properties @@ -41,5 +41,3 @@ okr.tenants.acme.user.champion.emails=peggimann@puzzle.ch,wunderland@puzzle.ch okr.tenants.acme.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:8544/realms/pitc/protocol/openid-connect/certs okr.tenants.acme.security.oauth2.frontend.issuer-url=http://localhost:8544/realms/pitc okr.tenants.acme.security.oauth2.frontend.client-id=acme_okr_staging - -spring.jpa.properties.hibernate.multi_tenant_connection_provider=ch.puzzle.okr.multitenancy.SchemaMultiTenantConnectionProviderH2 diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 1ed0f9df7a..997f4fde7f 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -46,7 +46,7 @@ okr.jwt.claim.email=email spring.jpa.properties.hibernate.multiTenancy=SCHEMA spring.jpa.properties.hibernate.tenant_identifier_resolver=ch.puzzle.okr.multitenancy.CurrentTenantIdentifierResolverImpl -spring.jpa.properties.hibernate.multi_tenant_connection_provider=ch.puzzle.okr.multitenancy.SchemaMultiTenantConnectionProviderPGSQL +spring.jpa.properties.hibernate.multi_tenant_connection_provider=ch.puzzle.okr.multitenancy.SchemaMultiTenantConnectionProvider okr.clientcustomization.favicon=assets/favicon.png okr.clientcustomization.logo=assets/images/okr-logo.svg diff --git a/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderInternalsTest.java b/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderInternalsTest.java index e8f62edadd..e8bc0dc7b0 100644 --- a/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderInternalsTest.java +++ b/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderInternalsTest.java @@ -14,7 +14,7 @@ public class SchemaMultiTenantConnectionProviderInternalsTest { private static final String TENANT_ID = "pitc"; - private static class ConfigurableConnectionProviderMock extends AbstractSchemaMultiTenantConnectionProvider { + private static class ConfigurableConnectionProviderMock extends SchemaMultiTenantConnectionProvider { @Override protected Properties getHibernateProperties() { diff --git a/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderTest.java b/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderTest.java index f2eeac80fe..e9a97a6d14 100644 --- a/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderTest.java +++ b/backend/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderTest.java @@ -8,7 +8,6 @@ import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; -import java.util.Properties; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -27,8 +26,7 @@ public class SchemaMultiTenantConnectionProviderTest { void getConnectionShouldSetSchemaWithOkrPrefix() throws SQLException { // arrange when(connection.createStatement()).thenReturn(statement); - AbstractSchemaMultiTenantConnectionProvider provider = new AbstractSchemaMultiTenantConnectionProvider() { - }; + SchemaMultiTenantConnectionProvider provider = new SchemaMultiTenantConnectionProvider(); // act provider.getConnection(TENANT_ID, connection); @@ -42,8 +40,7 @@ void getConnectionShouldSetSchemaWithOkrPrefix() throws SQLException { void getConnectionShouldSetSchemaWithoutOkrPrefixIfTenantIdIsDefaultTenantId() throws SQLException { // arrange when(connection.createStatement()).thenReturn(statement); - AbstractSchemaMultiTenantConnectionProvider provider = new AbstractSchemaMultiTenantConnectionProvider() { - }; + SchemaMultiTenantConnectionProvider provider = new SchemaMultiTenantConnectionProvider(); // act provider.getConnection(TenantContext.DEFAULT_TENANT_ID, connection);