generated from hmcts/spring-boot-template
-
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
Showing
22 changed files
with
299 additions
and
68 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
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
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
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
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
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 |
---|---|---|
@@ -1,12 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd"> | ||
<!--Please add all the false positives under the below section--> | ||
<suppress> | ||
<notes>False Positive | ||
<![CDATA[file name: jackson-databind-2.15.2.jar]]> | ||
</notes> | ||
<packageUrl regex="true">^pkg:maven/com\.fasterxml\.jackson\.core/jackson\-databind@.*$</packageUrl> | ||
<cve>CVE-2023-35116</cve> | ||
</suppress> | ||
|
||
<!--End of false positives section --> | ||
</suppressions> |
18 changes: 18 additions & 0 deletions
18
src/functionalTest/java/uk/gov/hmcts/opal/BaseFunctionalTest.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,18 @@ | ||
package uk.gov.hmcts.opal; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
import org.testcontainers.junit.jupiter.Container; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
@Testcontainers | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@ActiveProfiles({"functional"}) | ||
public class BaseFunctionalTest { | ||
|
||
@ServiceConnection | ||
@Container | ||
static PostgreSQLContainer databaseContainer = new PostgreSQLContainer<>("postgres:15-alpine"); | ||
} |
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
Empty file.
18 changes: 18 additions & 0 deletions
18
src/integrationTest/java/uk/gov/hmcts/opal/BaseIntegrationTest.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,18 @@ | ||
package uk.gov.hmcts.opal; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
import org.testcontainers.junit.jupiter.Container; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
@Testcontainers | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@ActiveProfiles({"integration"}) | ||
public class BaseIntegrationTest { | ||
|
||
@ServiceConnection | ||
@Container | ||
static PostgreSQLContainer databaseContainer = new PostgreSQLContainer<>("postgres:15-alpine"); | ||
} |
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
Empty file.
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
29 changes: 29 additions & 0 deletions
29
src/main/java/uk/gov/hmcts/opal/config/db/migration/FlywayConfiguration.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,29 @@ | ||
package uk.gov.hmcts.opal.config.db.migration; | ||
|
||
import org.flywaydb.core.Flyway; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@AutoConfigureAfter({ | ||
DataSourceAutoConfiguration.class, | ||
HibernateJpaAutoConfiguration.class | ||
}) | ||
@AutoConfigureBefore(FlywayAutoConfiguration.class) | ||
@Configuration | ||
@ConditionalOnClass(Flyway.class) | ||
@ConditionalOnProperty(prefix = "dbMigration", name = "runOnStartup", havingValue = "false") | ||
public class FlywayConfiguration { | ||
|
||
@Bean | ||
public FlywayMigrationStrategy flywayMigrationStrategy() { | ||
return new FlywayNoOpStrategy(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/uk/gov/hmcts/opal/config/db/migration/FlywayNoOpStrategy.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,19 @@ | ||
package uk.gov.hmcts.opal.config.db.migration; | ||
|
||
import org.flywaydb.core.Flyway; | ||
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class FlywayNoOpStrategy implements FlywayMigrationStrategy { | ||
|
||
@Override | ||
public void migrate(Flyway flyway) { | ||
Stream.of(flyway.info().all()) | ||
.filter(info -> !info.getState().isApplied()) | ||
.findFirst() | ||
.ifPresent(info -> { | ||
throw new PendingMigrationScriptException(info.getScript()); | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/uk/gov/hmcts/opal/config/db/migration/PendingMigrationScriptException.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,8 @@ | ||
package uk.gov.hmcts.opal.config.db.migration; | ||
|
||
public class PendingMigrationScriptException extends RuntimeException { | ||
|
||
public PendingMigrationScriptException(String script) { | ||
super("Found migration not yet applied: " + script); | ||
} | ||
} |
Oops, something went wrong.