/** * Asserts that the given expected DbUnit data set is equal to the actual DbUnit data set. Tables, * rows or columns that are not specified in the expected data set will be ignored. If an empty * table is specified in the expected data set, it will check that the actual table is also be * empty. * * @param schemaName The name of the schema that these data sets belong to, not null * @param expectedDataSet The expected data set, not null * @param actualDataSet The actual data set, not null * @throws AssertionError When the assertion fails. */ public void assertEqualDbUnitDataSets( String schemaName, IDataSet expectedDataSet, IDataSet actualDataSet) { SchemaFactory dbUnitDataSetBuilder = new SchemaFactory(); Schema expectedSchema = dbUnitDataSetBuilder.createSchemaForDbUnitDataSet(schemaName, expectedDataSet); List<String> expectedTableNames = expectedSchema.getTableNames(); Schema actualSchema = dbUnitDataSetBuilder.createSchemaForDbUnitDataSet( schemaName, actualDataSet, expectedTableNames); assertEqualSchemas(expectedSchema, actualSchema); }
public final Table getTable(String tableName, boolean caseSensitive) { if (caseSensitive) { return compositeTableMap.get(tableName); } else { final TableEntry tableEntry = tableMapInsensitive.get(tableName); if (tableEntry != null) { return tableEntry.getTable(); } final FunctionEntry entry = nullaryFunctionMapInsensitive.get(tableName); if (entry != null) { return ((TableMacro) entry.getFunction()).apply(ImmutableList.of()); } for (String name : schema.getTableNames()) { if (name.equalsIgnoreCase(tableName)) { return schema.getTable(name); } } return null; } }
public Set<String> getTableNames() { return schema.getTableNames(); }
public OptiqSchema(OptiqSchema parent, final Schema schema, String name) { this.parent = parent; this.schema = schema; this.name = name; assert (parent == null) == (this instanceof OptiqRootSchema); //noinspection unchecked this.compositeTableMap = CompositeMap.of( Maps.transformValues( tableMap, new com.google.common.base.Function<TableEntry, Table>() { public Table apply(TableEntry input) { return input.getTable(); } }), Maps.transformValues( Multimaps.filterEntries( functionMap, new Predicate<Map.Entry<String, FunctionEntry>>() { public boolean apply(Map.Entry<String, FunctionEntry> entry) { final Function function = entry.getValue().getFunction(); return function instanceof TableMacro && function.getParameters().isEmpty(); } }) .asMap(), new com.google.common.base.Function<Collection<FunctionEntry>, Table>() { public Table apply(Collection<FunctionEntry> input) { // At most one function with zero parameters. final TableMacro tableMacro = (TableMacro) input.iterator().next().getFunction(); return tableMacro.apply(ImmutableList.of()); } }), Compatible.INSTANCE.asMap( schema.getTableNames(), new com.google.common.base.Function<String, Table>() { public Table apply(String input) { return schema.getTable(input); } })); // TODO: include schema's functions in this map. this.compositeFunctionMap = Multimaps.transformValues( functionMap, new com.google.common.base.Function<FunctionEntry, Function>() { public Function apply(FunctionEntry input) { return input.getFunction(); } }); //noinspection unchecked this.compositeSubSchemaMap = CompositeMap.of( subSchemaMap, Compatible.INSTANCE.asMap( schema.getSubSchemaNames(), new com.google.common.base.Function<String, OptiqSchema>() { public OptiqSchema apply(String name) { return add(name, schema.getSubSchema(name)); } })); }