Skip to content

Commit 49beb2d

Browse files
committed
add a test
1 parent 67ea1d4 commit 49beb2d

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

core/src/test/java/net/jbock/compiler/CollectorTest.java

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ void invalidBound() {
430430
"}");
431431
JavaFileObject javaFile = forSourceLines("test.InvalidArguments", sourceLines);
432432
assertAbout(javaSources()).that(singletonList(javaFile))
433-
.processedWith(new Processor(true))
433+
.processedWith(new Processor())
434434
.failsToCompile()
435435
.withErrorContaining("The collector should return Set<String> but returns Set<Long>");
436436
}
@@ -461,7 +461,7 @@ void validBothMapperAndCollectorHaveTypeargsHard() {
461461
"}");
462462
JavaFileObject javaFile = forSourceLines("test.ValidArguments", sourceLines);
463463
assertAbout(javaSources()).that(singletonList(javaFile))
464-
.processedWith(new Processor(true))
464+
.processedWith(new Processor())
465465
.compilesWithoutError();
466466
}
467467

@@ -491,7 +491,7 @@ void invalidBothMapperAndCollectorHaveTypeargsBadCollectorBounds() {
491491
"}");
492492
JavaFileObject javaFile = forSourceLines("test.InvalidArguments", sourceLines);
493493
assertAbout(javaSources()).that(singletonList(javaFile))
494-
.processedWith(new Processor(true))
494+
.processedWith(new Processor())
495495
.failsToCompile()
496496
.withErrorContaining("There is a problem with the collector class: invalid bounds.");
497497
}
@@ -523,11 +523,43 @@ void invalidBothMapperAndCollectorHaveTypeargsUnresolvedCollectorTypearg() {
523523
"}");
524524
JavaFileObject javaFile = forSourceLines("test.InvalidArguments", sourceLines);
525525
assertAbout(javaSources()).that(singletonList(javaFile))
526-
.processedWith(new Processor(false))
526+
.processedWith(new Processor())
527527
.failsToCompile()
528528
.withErrorContaining("There is a problem with the collector class: could not resolve all type parameters.");
529529
}
530530

531+
@Test
532+
void validBothMapperCollectorAndResultTypeHaveTypeargs() {
533+
List<String> sourceLines = withImports(
534+
"@CommandLineArguments",
535+
"abstract class ValidArguments {",
536+
"",
537+
" @Parameter(shortName = 'x',",
538+
" repeatable = true,",
539+
" mappedBy = Map.class,",
540+
" collectedBy = Collect.class)",
541+
" abstract List<List<Result<String>>> map();",
542+
"",
543+
" static class Map<E, F> implements Supplier<Function<E, F>> {",
544+
" public Function<E, F> get() {",
545+
" return null;",
546+
" }",
547+
" }",
548+
"",
549+
" static class Collect<E extends List> implements Supplier<Collector<E, ?, List<E>>> {",
550+
" public Collector<E, ?, List<E>> get() {",
551+
" return null;",
552+
" }",
553+
" }",
554+
"",
555+
" static class Result<E> {}",
556+
"}");
557+
JavaFileObject javaFile = forSourceLines("test.ValidArguments", sourceLines);
558+
assertAbout(javaSources()).that(singletonList(javaFile))
559+
.processedWith(new Processor())
560+
.compilesWithoutError();
561+
}
562+
531563
@Test
532564
void bothMapperAndCollectorHaveTypeargsInvalidBoundsOnCollector() {
533565
List<String> sourceLines = withImports(

0 commit comments

Comments
 (0)