Search in sources :

Example 6 with ImmutableTable

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);
}
Also used : ImmutableTable(com.google.common.collect.ImmutableTable) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.junit.Test)

Example 7 with ImmutableTable

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);
}
Also used : ImmutableTable(com.google.common.collect.ImmutableTable) Test(org.junit.Test)

Aggregations

ImmutableTable (com.google.common.collect.ImmutableTable)7 ImmutableList (com.google.common.collect.ImmutableList)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)4 Test (org.junit.Test)4 CallingForm (com.google.api.codegen.viewmodel.CallingForm)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Nullable (javax.annotation.Nullable)2 SampleValueSet (com.google.api.codegen.SampleValueSet)1 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)1 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)1 InterfaceContext (com.google.api.codegen.config.InterfaceContext)1 MethodContext (com.google.api.codegen.config.MethodContext)1 MethodModel (com.google.api.codegen.config.MethodModel)1 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)1 SampleConfig (com.google.api.codegen.config.SampleConfig)1 SampleContext (com.google.api.codegen.config.SampleContext)1 SampleSpec (com.google.api.codegen.config.SampleSpec)1 GapicCodePathMapper (com.google.api.codegen.gapic.GapicCodePathMapper)1