/** * Updates SchemaInfoLevel builder with settings for a given info * level. * * @return SchemaInfoLevel builder */ public SchemaInfoLevelBuilder withInfoLevel(final InfoLevel infoLevel) { if (infoLevel == null) { return this; } final int infoLevelOrdinal = infoLevel.ordinal(); for (final SchemaInfoRetrieval schemaInfoRetrieval: SchemaInfoRetrieval .values()) { final int schemaInfoLevelOrdinal = schemaInfoRetrieval.getInfoLevel() .ordinal(); if (schemaInfoLevelOrdinal <= infoLevelOrdinal) { schemaInfoRetrievals.put(schemaInfoRetrieval, true); } } return this; }
public static InfoLevel valueOfFromString(final String infoLevelValue) { try { return InfoLevel.valueOf(infoLevelValue); } catch (final IllegalArgumentException | NullPointerException e) { LOGGER.log(Level.INFO, new StringFormat("Unknown infolevel <%s>", infoLevelValue)); return unknown; } }
private Stream<InfoLevel> infoLevels() { return Arrays.stream(InfoLevel.values()) .filter(infoLevel -> infoLevel != InfoLevel.unknown); }
@Test public void commandLineWithTitle(final DatabaseConnectionInfo connectionInfo) throws Exception { assertAll(outputFormats() .flatMap(outputFormat -> commands().map(command -> () -> { final String referenceFile = referenceFile(command, outputFormat); final Map<String, String> argsMap = new HashMap<>(); argsMap.put("schemas", ".*\\.(?!FOR_LINT).*"); argsMap.put("infolevel", InfoLevel.standard.name()); argsMap.put("title", "Database Design for Books and Publishers"); assertThat(outputOf(commandlineExecution(connectionInfo, command, argsMap, outputFormat)), hasSameContentAndTypeAs(classpathResource(TITLE_OUTPUT + referenceFile), outputFormat)); }))); }
@Test public void noEmptyTables(final TestContext testContext, final DatabaseConnectionInfo connectionInfo) throws Exception { clean(HIDE_EMPTY_TABLES_OUTPUT); final String referenceFile = testContext.testMethodName() + ".txt"; final Map<String, String> argsMap = new HashMap<>(); argsMap.put("infolevel", InfoLevel.maximum.name()); argsMap.put("noinfo", "true"); argsMap.put("noemptytables", "true"); assertThat(outputOf(commandlineExecution(connectionInfo, SchemaTextDetailType.schema.name(), argsMap, TextOutputFormat.text)), hasSameContentAs(classpathResource(HIDE_EMPTY_TABLES_OUTPUT + referenceFile))); }
/** * Updates SchemaInfoLevel builder with settings for a given info * level. * * @return SchemaInfoLevel builder */ public SchemaInfoLevelBuilder withInfoLevel(final InfoLevel infoLevel) { if (infoLevel == null) { return this; } final int infoLevelOrdinal = infoLevel.ordinal(); for (final SchemaInfoRetrieval schemaInfoRetrieval: SchemaInfoRetrieval .values()) { final int schemaInfoLevelOrdinal = schemaInfoRetrieval.getInfoLevel() .ordinal(); if (schemaInfoLevelOrdinal <= infoLevelOrdinal) { schemaInfoRetrievals.put(schemaInfoRetrieval, true); } } return this; }
public static InfoLevel valueOfFromString(final String infoLevelValue) { try { return InfoLevel.valueOf(infoLevelValue); } catch (final IllegalArgumentException | NullPointerException e) { LOGGER.log(Level.INFO, new StringFormat("Unknown infolevel <%s>", infoLevelValue)); return unknown; } }
@Test public void spinThroughMain(final DatabaseConnectionInfo connectionInfo) throws Exception { assertAll(infoLevels().flatMap(infoLevel -> outputFormats() .flatMap(outputFormat -> schemaTextDetailTypes() .map(schemaTextDetailType -> () -> { final String referenceFile = referenceFile(schemaTextDetailType, infoLevel, outputFormat); final String command = schemaTextDetailType.name(); final Map<String, String> argsMap = new HashMap<>(); argsMap.put("sequences", ".*"); argsMap.put("synonyms", ".*"); argsMap.put("routines", ".*"); argsMap.put("noinfo", Boolean.FALSE.toString()); argsMap.put("infolevel", infoLevel.name()); assertThat(outputOf(commandlineExecution(connectionInfo, command, argsMap, "/hsqldb.INFORMATION_SCHEMA.config.properties", outputFormat)), hasSameContentAndTypeAs(classpathResource(SPIN_THROUGH_OUTPUT + referenceFile), outputFormat)); })))); }
private Stream<InfoLevel> infoLevels() { return Arrays.stream(InfoLevel.values()) .filter(infoLevel -> infoLevel != InfoLevel.unknown); }
private String referenceFile(final Operation operation, final InfoLevel infoLevel, final OutputFormat outputFormat) { final String referenceFile = String.format("%d%d.%s_%s.%s", operation.ordinal(), infoLevel.ordinal(), operation, infoLevel, outputFormat.getFormat()); return referenceFile; }
public static InfoLevel valueOfFromString(final String infoLevelValue) { try { return InfoLevel.valueOf(infoLevelValue); } catch (final IllegalArgumentException | NullPointerException e) { LOGGER.log(Level.INFO, new StringFormat("Unknown infolevel <%s>", infoLevelValue)); return unknown; } }
argsMap.put("routines", ".*"); argsMap.put("noinfo", Boolean.FALSE.toString()); argsMap.put("infolevel", infoLevel.name());
private String referenceFile(final SchemaTextDetailType schemaTextDetailType, final InfoLevel infoLevel, final OutputFormat outputFormat) { final String referenceFile = String.format("%d%d.%s_%s.%s", schemaTextDetailType.ordinal(), infoLevel.ordinal(), schemaTextDetailType, infoLevel, outputFormat.getFormat()); return referenceFile; }
public static InfoLevel valueOfFromString(final String infoLevelValue) { try { return InfoLevel.valueOf(infoLevelValue); } catch (final IllegalArgumentException | NullPointerException e) { LOGGER.log(Level.INFO, new StringFormat("Unknown infolevel <%s>", infoLevelValue)); return unknown; } }
@Test public void overrideMetadataRetrievalStrategy(final TestContext testContext, final DatabaseConnectionInfo connectionInfo) throws Exception { clean(METADATA_RETRIEVAL_STRATEGY_OUTPUT); final SchemaTextDetailType schemaTextDetailType = SchemaTextDetailType.schema; final InfoLevel infoLevel = InfoLevel.minimum; final OutputFormat outputFormat = TextOutputFormat.text; final Config config = new Config(); config.put("schemacrawler.schema.retrieval.strategy.tables", MetadataRetrievalStrategy.data_dictionary_all.name()); final Map<String, String> argsMap = new HashMap<>(); argsMap.put("infolevel", infoLevel.name()); argsMap.put("noinfo", "true"); // Check that System.err has an error assertThat(outputOf(commandlineExecution(connectionInfo, schemaTextDetailType.name(), argsMap, config, outputFormat)), hasNoContent()); final String errorLog = err.getFileContents(); assertThat(errorLog, containsString("No tables SQL provided")); }
/** * Updates SchemaInfoLevel builder with settings for a given info * level. * * @return SchemaInfoLevel builder */ public SchemaInfoLevelBuilder withInfoLevel(final InfoLevel infoLevel) { if (infoLevel == null) { return this; } final int infoLevelOrdinal = infoLevel.ordinal(); for (final SchemaInfoRetrieval schemaInfoRetrieval: SchemaInfoRetrieval .values()) { final int schemaInfoLevelOrdinal = schemaInfoRetrieval.getInfoLevel() .ordinal(); if (schemaInfoLevelOrdinal <= infoLevelOrdinal) { schemaInfoRetrievals.put(schemaInfoRetrieval, true); } } return this; }
/** * Updates SchemaInfoLevel builder with settings for a given info * level. * * @return SchemaInfoLevel builder */ public SchemaInfoLevelBuilder withInfoLevel(final InfoLevel infoLevel) { if (infoLevel == null) { return this; } final int infoLevelOrdinal = infoLevel.ordinal(); for (final SchemaInfoRetrieval schemaInfoRetrieval: SchemaInfoRetrieval .values()) { final int schemaInfoLevelOrdinal = schemaInfoRetrieval.getInfoLevel() .ordinal(); if (schemaInfoLevelOrdinal <= infoLevelOrdinal) { schemaInfoRetrievals.put(schemaInfoRetrieval, true); } } return this; }