Skip to content

Commit

Permalink
Add coverage for text plugin command
Browse files Browse the repository at this point in the history
  • Loading branch information
sualeh committed Aug 17, 2024
1 parent 48dd555 commit e86af51
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package schemacrawler.test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static schemacrawler.test.utility.FileHasContent.classpathResource;
import static schemacrawler.test.utility.FileHasContent.hasSameContentAs;
import static schemacrawler.test.utility.FileHasContent.outputOf;
import java.util.Collection;
import org.junit.jupiter.api.Test;
import schemacrawler.test.utility.ResolveTestContext;
import schemacrawler.test.utility.TestContext;
import schemacrawler.test.utility.TestWriter;
import schemacrawler.tools.command.text.schema.SchemaTextCommandProvider;
import schemacrawler.tools.executable.commandline.PluginCommand;
import schemacrawler.tools.executable.commandline.PluginCommandOption;

@ResolveTestContext
public class PluginCommandTest {

@Test
public void testSchemaTextCommandProviderPluginCommand(final TestContext testContext) {
final PluginCommand pluginCommand = new SchemaTextCommandProvider().getCommandLineCommand();

assertThat(pluginCommand.getName(), is("command:schema"));

final TestWriter testout = new TestWriter();
try (final TestWriter out = testout) {
out.println(pluginCommand.getHelpHeader());
final String[] helpDescription = pluginCommand.getHelpDescription().get();
writeStringArray(out, helpDescription);
out.println();
final Collection<PluginCommandOption> options = pluginCommand.getOptions();
for (final PluginCommandOption pluginCommandOption : options) {
out.println(pluginCommandOption.getName());
final String[] optionHelpText = pluginCommandOption.getHelpText();
writeStringArray(out, optionHelpText);
out.println();
}
final String[] helpFooter = pluginCommand.getHelpFooter().get();
writeStringArray(out, helpFooter);
}
assertThat(
outputOf(testout), hasSameContentAs(classpathResource(testContext.testMethodFullName())));
}

private void writeStringArray(final TestWriter out, final String[] helpFooter) {
for (final String helpLine : helpFooter) {
out.println(helpLine);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
** Generate text output to show details of a schema
Applies to all commands that show schema information

no-info
Hide or show SchemaCrawler header and database information
--no-info=<boolean>
<boolean> can be true or false
Optional, defaults to false

no-remarks
Hide or show table and column remarks
--no-remarks=<boolean>
<boolean> can be true or false
Optional, defaults to false

portable-names
Allow for easy comparison between databases, by hiding or showing foreign key names, constraint names, trigger names, specific names for routines, or index and primary key names, and fully-qualified table names
--portable-names=<boolean>
<boolean> can be true or false
Optional, defaults to false

sort-columns
Sort columns in a table alphabetically
--sort-columns=<sortcolumns>
<sortcolumns> can be true or false
Optional, defaults to false

sort-tables
Sort tables alphabetically
--sort-tables=<sorttables>
<sorttables> can be true or false
Optional, defaults to true

sort-routines
Sort routines alphabetically
--sort-routines=<sortroutines>
<sortroutines> can be true or false
Optional, defaults to true

Add command options to the `execute` command in the SchemaCrawler Shell

0 comments on commit e86af51

Please sign in to comment.