Search in sources :

Example 11 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbGenerateDocsCommandTest method testRun.

@Test
public void testRun() throws Exception {
    Liquibase liquibase = Mockito.mock(Liquibase.class);
    generateDocsCommand.run(new Namespace(ImmutableMap.of("output", ImmutableList.of("/tmp/docs"))), liquibase);
    Mockito.verify(liquibase).generateDocumentation("/tmp/docs");
}
Also used : Liquibase(liquibase.Liquibase) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 12 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbClearChecksumsCommandTest method testRun.

@Test
public void testRun() throws Exception {
    final Liquibase liquibase = Mockito.mock(Liquibase.class);
    clearChecksums.run(new Namespace(ImmutableMap.of()), liquibase);
    Mockito.verify(liquibase).clearCheckSums();
}
Also used : Liquibase(liquibase.Liquibase) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 13 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbDropAllCommandTest method testRun.

@Test
public void testRun() throws Exception {
    final String databaseUrl = getDatabaseUrl();
    final TestMigrationConfiguration conf = createConfiguration(databaseUrl);
    // Create some data
    new DbMigrateCommand<>(TestMigrationConfiguration::getDataSource, TestMigrationConfiguration.class, "migrations.xml").run(null, new Namespace(ImmutableMap.of()), conf);
    // Drop it
    dropAllCommand.run(null, new Namespace(ImmutableMap.of()), conf);
    // After we dropped data and schema, we should be able to create the "persons" table again
    try (Handle handle = new DBI(databaseUrl, "sa", "").open()) {
        handle.execute("create table persons(id int, name varchar(255))");
    }
}
Also used : DBI(org.skife.jdbi.v2.DBI) Namespace(net.sourceforge.argparse4j.inf.Namespace) Handle(org.skife.jdbi.v2.Handle) Test(org.junit.Test)

Example 14 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbPrepareRollbackCommandTest method testRun.

@Test
public void testRun() throws Exception {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    prepareRollbackCommand.setOutputStream(new PrintStream(baos));
    prepareRollbackCommand.run(null, new Namespace(ImmutableMap.of()), conf);
    assertThat(baos.toString(UTF_8)).contains("ALTER TABLE PUBLIC.persons DROP COLUMN email;").contains("DROP TABLE PUBLIC.persons;");
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Example 15 with Namespace

use of net.sourceforge.argparse4j.inf.Namespace in project dropwizard by dropwizard.

the class DbRollbackCommandTest method testRollbackNChangesAsDryRun.

@Test
public void testRollbackNChangesAsDryRun() throws Exception {
    // Migrate some DDL changes to the database
    migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
    // Print out the change that rollbacks the second change
    rollbackCommand.setOutputStream(new PrintStream(baos, true));
    rollbackCommand.run(null, new Namespace(ImmutableMap.of("count", 1, "dry-run", true)), conf);
    assertThat(baos.toString(UTF_8)).containsIgnoringCase("ALTER TABLE PUBLIC.persons DROP COLUMN email;");
}
Also used : PrintStream(java.io.PrintStream) Namespace(net.sourceforge.argparse4j.inf.Namespace) Test(org.junit.Test)

Aggregations

Namespace (net.sourceforge.argparse4j.inf.Namespace)46 Test (org.junit.Test)36 PrintStream (java.io.PrintStream)9 Handle (org.skife.jdbi.v2.Handle)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Liquibase (liquibase.Liquibase)6 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)6 DBI (org.skife.jdbi.v2.DBI)6 ArgumentParser (net.sourceforge.argparse4j.inf.ArgumentParser)5 IOException (java.io.IOException)4 Properties (java.util.Properties)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 File (java.io.File)3 Configuration (io.dropwizard.Configuration)2 Bootstrap (io.dropwizard.setup.Bootstrap)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Element (org.w3c.dom.Element)2