use of uk.gov.pay.adminusers.utils.DatabaseTestHelper in project pay-adminusers by alphagov.
the class DaoTestBase method setup.
@BeforeAll
public static void setup() throws Exception {
final Properties properties = new Properties();
properties.put("javax.persistence.jdbc.driver", postgres.getDriverClass());
properties.put("javax.persistence.jdbc.url", postgres.getConnectionUrl());
properties.put("javax.persistence.jdbc.user", postgres.getUsername());
properties.put("javax.persistence.jdbc.password", postgres.getPassword());
JpaPersistModule jpaModule = new JpaPersistModule("AdminUsersUnit").properties(properties);
databaseHelper = new DatabaseTestHelper(Jdbi.create(postgres.getConnectionUrl(), postgres.getUsername(), postgres.getPassword()));
try (Connection connection = DriverManager.getConnection(postgres.getConnectionUrl(), postgres.getUsername(), postgres.getPassword())) {
Liquibase migrator = new Liquibase("config/initial-db-state.xml", new ClassLoaderResourceAccessor(), new JdbcConnection(connection));
Liquibase migrator2 = new Liquibase("migrations.xml", new ClassLoaderResourceAccessor(), new JdbcConnection(connection));
migrator.update("");
migrator2.update("");
}
env = GuicedTestEnvironment.from(jpaModule).start();
}
use of uk.gov.pay.adminusers.utils.DatabaseTestHelper in project pay-adminusers by alphagov.
the class DropwizardAppWithPostgresExtension method beforeAll.
@Override
public void beforeAll(ExtensionContext context) throws Exception {
LOGGER.info("Clearing database.");
app.getApplication().run("db", "drop-all", "--confirm-delete-everything", configFilePath);
app.getApplication().run("migrateToInitialDbState", configFilePath);
doSecondaryDatabaseMigration();
restoreDropwizardsLogging();
DataSourceFactory dataSourceFactory = app.getConfiguration().getDataSourceFactory();
databaseTestHelper = new DatabaseTestHelper(Jdbi.create(dataSourceFactory.getUrl(), dataSourceFactory.getUser(), dataSourceFactory.getPassword()));
}
Aggregations