use of com.google.common.collect.ImmutableTable in project querydsl by querydsl.
the class GroupBy4Test method test7.
@Test
public void test7() {
List<Table> data = Lists.newArrayList();
data.add(new Table("1", "abc", "111"));
data.add(new Table("1", "pqr", "222"));
data.add(new Table("2", "abc", "333"));
data.add(new Table("2", "pqr", "444"));
data.add(new Table("3", "abc", "555"));
data.add(new Table("3", "pqr", "666"));
data.add(new Table("3", "pqr", "777"));
QGroupBy4Test_Table table = QGroupBy4Test_Table.table;
Map<String, com.google.common.collect.Table<String, String, Map<String, List<String>>>> transform = CollQueryFactory.from(table, data).transform(groupBy(table.col1).as(GuavaGroupBy.table(table.col1, table.col2, map(table.col2, list(table.col3)))));
ImmutableMap<String, com.google.common.collect.Table<String, String, Map<String, List<String>>>> expected = ImmutableMap.<String, com.google.common.collect.Table<String, String, Map<String, List<String>>>>builder().put("1", ImmutableTable.<String, String, Map<String, List<String>>>builder().put("1", "abc", ImmutableMap.<String, List<String>>of("abc", ImmutableList.of("111"))).put("1", "pqr", ImmutableMap.<String, List<String>>of("pqr", ImmutableList.of("222"))).build()).put("2", ImmutableTable.<String, String, Map<String, List<String>>>builder().put("2", "abc", ImmutableMap.<String, List<String>>of("abc", ImmutableList.of("333"))).put("2", "pqr", ImmutableMap.<String, List<String>>of("pqr", ImmutableList.of("444"))).build()).put("3", ImmutableTable.<String, String, Map<String, List<String>>>builder().put("3", "abc", ImmutableMap.<String, List<String>>of("abc", ImmutableList.of("555"))).put("3", "pqr", ImmutableMap.<String, List<String>>of("pqr", ImmutableList.of("666", "777"))).build()).build();
assertEquals(expected, transform);
}
use of com.google.common.collect.ImmutableTable in project querydsl by querydsl.
the class GroupBy4Test method test4.
@Test
public void test4() {
List<Table> data = Lists.newArrayList();
data.add(new Table("1", "abc", "111"));
data.add(new Table("1", "pqr", "222"));
data.add(new Table("2", "abc", "333"));
data.add(new Table("2", "pqr", "444"));
data.add(new Table("3", "abc", "555"));
data.add(new Table("3", "pqr", "666"));
QGroupBy4Test_Table table = QGroupBy4Test_Table.table;
com.google.common.collect.Table<String, String, String> transform = CollQueryFactory.from(table, data).transform(groupBy(table.col1).asTable(table.col2, table.col3));
ImmutableTable<String, String, String> expected = ImmutableTable.<String, String, String>builder().put("1", "abc", "111").put("1", "pqr", "222").put("2", "abc", "333").put("2", "pqr", "444").put("3", "abc", "555").put("3", "pqr", "666").build();
assertEquals(expected, transform);
}
Aggregations