@Test public void testJoinTable() { JoinTable operation = SchemaOperations.joinTable("users", "u", "id", "name") .with("addresses", "a", "u.id = a.user_id", "address") .into("users"); ImmutableMap<String, List<String>> expectedSourceColumns = ImmutableMap.<String, List<String>>builder() .put("u", Lists.newArrayList("id", "name")) .put("a", Lists.newArrayList("address")) .build(); Map<String, String> expectedJoinConditions = ImmutableMap.of("a", "u.id = a.user_id"); Map<String, String> expectedSourceTables = ImmutableMap.of("u", "users", "a", "addresses"); assertEquals("users", operation.getTargetTableName()); assertEquals(expectedJoinConditions, operation.getJoinConditions()); assertEquals(expectedSourceTables, operation.getSourceTables()); assertEquals(expectedSourceColumns, operation.getSourceColumns()); }
JoinTable(String sourceTable, String alias, String... columns) { checkArgument(!Strings.isNullOrEmpty(sourceTable), "You must specify a 'sourceTable'."); checkArgument(!Strings.isNullOrEmpty(alias), "You must specify a 'alias'."); this.sourceTables = Maps.newLinkedHashMap(); this.sourceColumns = Maps.newLinkedHashMap(); this.joinConditions = Maps.newLinkedHashMap(); sourceTables.put(alias, sourceTable); sourceColumns.put(alias, ImmutableList.copyOf(columns)); }
JoinTable implements SchemaOperation { JoinTable(String sourceTable, String alias, String... columns) { checkArgument(!Strings.isNullOrEmpty(sourceTable), "You must specify a 'sourceTable'."); checkArgument(!Strings.isNullOrEmpty(alias), "You must specify a 'alias'."); this.sourceTables = Maps.newLinkedHashMap(); this.sourceColumns = Maps.newLinkedHashMap(); this.joinConditions = Maps.newLinkedHashMap(); sourceTables.put(alias, sourceTable); sourceColumns.put(alias, ImmutableList.copyOf(columns)); } }
JoinTable implements SchemaOperation { JoinTable(String sourceTable, String alias, String... columns) { checkArgument(!Strings.isNullOrEmpty(sourceTable), "You must specify a 'sourceTable'."); checkArgument(!Strings.isNullOrEmpty(alias), "You must specify a 'alias'."); this.sourceTables = Maps.newLinkedHashMap(); this.sourceColumns = Maps.newLinkedHashMap(); this.joinConditions = Maps.newLinkedHashMap(); sourceTables.put(alias, sourceTable); sourceColumns.put(alias, ImmutableList.copyOf(columns)); } JoinTable(String sourceTable, String alias, String... columns); }
JoinTable implements SchemaOperation { JoinTable(String sourceTable, String alias, String... columns) { checkArgument(!Strings.isNullOrEmpty(sourceTable), "You must specify a 'sourceTable'."); checkArgument(!Strings.isNullOrEmpty(alias), "You must specify a 'alias'."); this.sourceTables = Maps.newLinkedHashMap(); this.sourceColumns = Maps.newLinkedHashMap(); this.joinConditions = Maps.newLinkedHashMap(); sourceTables.put(alias, sourceTable); sourceColumns.put(alias, ImmutableList.copyOf(columns)); } JoinTable(String sourceTable, String alias, String... columns); ImmutableMap<String, String> getSourceTables(); ImmutableMap<String, List<String>> getSourceColumns(); ImmutableMap<String, String> getJoinConditions(); JoinTable with(String sourceTable, String alias, String joinCondition, String... columns); JoinTable into(String tableName); }
JoinTable implements SchemaOperation { JoinTable(String sourceTable, String alias, String... columns) { checkArgument(!Strings.isNullOrEmpty(sourceTable), "You must specify a 'sourceTable'."); checkArgument(!Strings.isNullOrEmpty(alias), "You must specify a 'alias'."); this.sourceTables = Maps.newLinkedHashMap(); this.sourceColumns = Maps.newLinkedHashMap(); this.joinConditions = Maps.newLinkedHashMap(); sourceTables.put(alias, sourceTable); sourceColumns.put(alias, ImmutableList.copyOf(columns)); } JoinTable(String sourceTable, String alias, String... columns); ImmutableMap<String, String> getSourceTables(); ImmutableMap<String, List<String>> getSourceColumns(); ImmutableMap<String, String> getJoinConditions(); JoinTable with(String sourceTable, String alias, String joinCondition, String... columns); JoinTable into(String tableName);  }