generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15fadc7
commit 2a2cc09
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...udit/src/test/kotlin/uk/gov/justice/digital/hmpps/audit/service/OptimisationTablesTest.kt
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,29 @@ | ||
package uk.gov.justice.digital.hmpps.audit.service | ||
|
||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.hasSize | ||
import org.junit.jupiter.api.Assertions.assertDoesNotThrow | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.Mockito.mock | ||
import org.mockito.Mockito.verify | ||
import org.springframework.jdbc.core.JdbcTemplate | ||
import org.springframework.transaction.support.TransactionSynchronizationManager | ||
|
||
class OptimisationTablesTest { | ||
@Test | ||
fun `handles non-Oracle database`() { | ||
assertDoesNotThrow { OptimisationTables(null).rebuild(123) } | ||
} | ||
|
||
@Test | ||
fun `creates afterCommit hook`() { | ||
val jdbcTemplate = mock(JdbcTemplate::class.java) | ||
TransactionSynchronizationManager.initSynchronization() | ||
|
||
OptimisationTables(OptimisationTablesRebuild(jdbcTemplate)).rebuild(123) | ||
|
||
assertThat(TransactionSynchronizationManager.getSynchronizations(), hasSize(1)) | ||
TransactionSynchronizationManager.getSynchronizations()[0].afterCommit() | ||
verify(jdbcTemplate).execute("call PKG_TRIGGERSUPPORT.PROCREBUILDOPTTABLES(123)") | ||
} | ||
} |