use of org.jdbi.v3.core.internal.exceptions.Unchecked in project jdbi by jdbi.
the class TestGuavaCollectors method testMultimapCollector.
@SuppressWarnings("unchecked")
private <M extends Multimap<Long, String>> void testMultimapCollector(Class<? extends Multimap> erasedType, GenericType<M> genericType) {
JdbiCollectors registry = h2Extension.getJdbi().getConfig(JdbiCollectors.class);
assertThat(registry.findElementTypeFor(genericType.getType())).contains(new GenericType<Map.Entry<Long, String>>() {
}.getType());
Collector<Map.Entry<Long, String>, ?, M> collector = (Collector<Map.Entry<Long, String>, ?, M>) registry.findFor(genericType.getType()).orElseThrow(() -> new IllegalStateException("Missing collector for " + genericType));
M map = Stream.of(entry(1L, "foo"), entry(2L, "bar")).collect(collector);
assertThat(map).isInstanceOf(erasedType).containsAllEntriesOf(ImmutableMultimap.of(1L, "foo", 2L, "bar"));
}
Aggregations