use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbLocksCommandTest method testFailsWhenBothListAndRelease.
@Test
public void testFailsWhenBothListAndRelease() throws Exception {
final Liquibase liquibase = Mockito.mock(Liquibase.class);
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> locksCommand.run(new Namespace(ImmutableMap.of("list", true, "release", true)), liquibase)).withMessage("Must specify either --list or --force-release");
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbMigrateDifferentFileCommandTest method testRunForFileFromFilesystem.
@Test
public void testRunForFileFromFilesystem() throws Exception {
final String migrationsPath = new File(Resources.getResource("migrations.xml").toURI()).getAbsolutePath();
migrateCommand.run(null, new Namespace(ImmutableMap.of("migrations-file", migrationsPath)), conf);
try (Handle handle = new DBI(databaseUrl, "sa", "").open()) {
assertThat(handle.select("select * from persons")).hasSize(1);
}
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbFastForwardCommandTest method testFastForwardFirst.
@Test
public void testFastForwardFirst() throws Exception {
// Create the "persons" table manually
try (Handle handle = dbi.open()) {
handle.execute("create table persons(id int, name varchar(255))");
}
// Fast-forward one change
fastForwardCommand.run(null, new Namespace(ImmutableMap.of("all", false, "dry-run", false)), conf);
// 2nd and 3rd migrations is performed
new DbMigrateCommand<>(TestMigrationConfiguration::getDataSource, TestMigrationConfiguration.class, "migrations.xml").run(null, new Namespace(ImmutableMap.of()), conf);
// 1 entry has been added to the persons table
try (Handle handle = dbi.open()) {
assertThat(handle.createQuery("select count(*) from persons").mapTo(Integer.class).first()).isEqualTo(1);
}
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbFastForwardCommandTest method testFastForwardAll.
@Test
public void testFastForwardAll() throws Exception {
// Create the "persons" table manually and add some data
try (Handle handle = dbi.open()) {
handle.execute("create table persons(id int, name varchar(255))");
handle.execute("insert into persons (id, name) values (12, 'Greg Young')");
}
// Fast-forward all the changes
fastForwardCommand.run(null, new Namespace(ImmutableMap.of("all", true, "dry-run", false)), conf);
// No migrations is performed
new DbMigrateCommand<>(TestMigrationConfiguration::getDataSource, TestMigrationConfiguration.class, "migrations.xml").run(null, new Namespace(ImmutableMap.of()), conf);
// Nothing is added to the persons table
try (Handle handle = dbi.open()) {
assertThat(handle.createQuery("select count(*) from persons").mapTo(Integer.class).first()).isEqualTo(1);
}
}
use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.
the class DbPrepareRollbackCommandTest method testPrepareOnlyChange.
@Test
public void testPrepareOnlyChange() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
prepareRollbackCommand.setOutputStream(new PrintStream(baos));
prepareRollbackCommand.run(null, new Namespace(ImmutableMap.of("count", 1)), conf);
assertThat(baos.toString(UTF_8)).contains("DROP TABLE PUBLIC.persons;");
}
Aggregations