-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing core functionality "set schema" of AbstractSchemaMultiTenantC…
…onnectionProvider
- Loading branch information
1 parent
d63508b
commit 7ff7cdf
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...end/src/test/java/ch/puzzle/okr/multitenancy/SchemaMultiTenantConnectionProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ch.puzzle.okr.multitenancy; | ||
|
||
import ch.puzzle.okr.test.SpringIntegrationTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mock; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@SpringIntegrationTest | ||
public class SchemaMultiTenantConnectionProviderTest { | ||
@Mock | ||
Connection connection; | ||
@Mock | ||
Statement statement; | ||
|
||
private static final String TENANT_ID = "pitc"; | ||
|
||
@Test | ||
void testSetSchemaOfTenant() throws SQLException { | ||
when(connection.createStatement()).thenReturn(statement); | ||
|
||
AbstractSchemaMultiTenantConnectionProvider provider = new AbstractSchemaMultiTenantConnectionProvider() { | ||
@Override | ||
protected String getHibernatePropertiesFilePaths() { | ||
return null; | ||
} | ||
}; | ||
provider.getConnection(TENANT_ID, connection); | ||
|
||
verify(statement).execute("SET SCHEMA 'okr_" + TENANT_ID + "';"); | ||
} | ||
|
||
} |