mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
Add tests
This commit is contained in:
parent
9a6fd4e75a
commit
efffbfa975
@ -34,6 +34,17 @@ public abstract class AbstractGroupByTest {
|
||||
row(3, "post 3", 6, "comment 6")
|
||||
);
|
||||
|
||||
protected static final Projectable BASIC_RESULTS_UNORDERED = projectable(
|
||||
row(null, "null post", 8, "comment 8"),
|
||||
row(null, "null post", 7, "comment 7"),
|
||||
row(1, "post 1", 2, "comment 2"),
|
||||
row(1, "post 1", 1, "comment 1"),
|
||||
row(2, "post 2", 4, "comment 4"),
|
||||
row(1, "post 1", 3, "comment 3"),
|
||||
row(3, "post 3", 6, "comment 6"),
|
||||
row(2, "post 2", 5, "comment 5")
|
||||
);
|
||||
|
||||
protected static final Projectable MAP_RESULTS = projectable(
|
||||
row(null, "null post", pair(7, "comment 7")),
|
||||
row(null, "null post", pair(8, "comment 8")),
|
||||
|
||||
@ -17,7 +17,7 @@ package com.querydsl.core.group;
|
||||
import static com.querydsl.core.group.GroupBy.groupBy;
|
||||
import static com.querydsl.core.group.GroupBy.list;
|
||||
import static com.querydsl.core.group.GroupBy.map;
|
||||
import static com.querydsl.core.group.GroupBy.set;
|
||||
import static com.querydsl.core.group.GroupBy.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@ -44,6 +44,18 @@ public class GroupByMapTest extends AbstractGroupByTest {
|
||||
assertEquals(4, results.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Set_By_Sorted() {
|
||||
Map<Integer, Group> results = BASIC_RESULTS
|
||||
.transform(groupBy(postId).as(postName, sortedSet(commentId)));
|
||||
|
||||
Group group = results.get(1);
|
||||
Iterator<Integer> it = group.getSet(commentId).iterator();
|
||||
assertEquals(1, it.next().intValue());
|
||||
assertEquals(2, it.next().intValue());
|
||||
assertEquals(3, it.next().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void First_Set_And_List() {
|
||||
Map<Integer, Group> results = BASIC_RESULTS.transform(
|
||||
@ -99,6 +111,19 @@ public class GroupByMapTest extends AbstractGroupByTest {
|
||||
assertEquals("comment 2", comments.get(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Map_Sorted() {
|
||||
Map<Integer, Group> results = MAP_RESULTS.transform(
|
||||
groupBy(postId).as(postName, sortedMap(commentId, commentText)));
|
||||
|
||||
Group group = results.get(1);
|
||||
|
||||
Iterator<Map.Entry<Integer, String>> it = group.getMap(commentId, commentText).entrySet().iterator();
|
||||
assertEquals(1, it.next().getKey().intValue());
|
||||
assertEquals(2, it.next().getKey().intValue());
|
||||
assertEquals(3, it.next().getKey().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Map2() {
|
||||
Map<Integer, Map<Integer, String>> results = MAP2_RESULTS.transform(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user