@Test public void generateNested() { AnnotatedCommandSourceGeneratorProcessor processor = new AnnotatedCommandSourceGeneratorProcessor(); Compilation compilation = javac() .withProcessors(processor) .compile(JavaFileObjects.forResource( "picocli/examples/PopulateFlagsMain.java")); assertThat(compilation).succeeded(); assertThat(compilation) .generatedFile(StandardLocation.SOURCE_OUTPUT, "generated/picocli/examples/PopulateFlagsMain.java") .hasSourceEquivalentTo(JavaFileObjects.forResource("generated/picocli/examples/PopulateFlagsMain.java")); }
@Test public void generate1() { AnnotatedCommandSourceGeneratorProcessor processor = new AnnotatedCommandSourceGeneratorProcessor(); Compilation compilation = javac() .withProcessors(processor) .compile(JavaFileObjects.forResource( "picocli/codegen/aot/graalvm/Example.java")); assertThat(compilation).succeeded(); assertThat(compilation) .generatedFile(StandardLocation.SOURCE_OUTPUT, "generated/picocli/codegen/aot/graalvm/Example.java") .hasSourceEquivalentTo(JavaFileObjects.forResource("generated/picocli/codegen/aot/graalvm/Example.java")); }
@Ignore @Test public void generateNested2() { AnnotatedCommandSourceGeneratorProcessor processor = new AnnotatedCommandSourceGeneratorProcessor(); Compilation compilation = javac() .withProcessors(processor) .compile(JavaFileObjects.forResource( "picocli/examples/subcommands/ParentCommandDemo.java")); assertThat(compilation).succeeded(); assertThat(compilation) .generatedFile(StandardLocation.SOURCE_OUTPUT, "generated/examples/subcommands/ParentCommandDemo.java") .hasSourceEquivalentTo(JavaFileObjects.forResource("generated/examples/subcommands/ParentCommandDemo.java")); } }
/** Asserts that compilation generated a source file for a type with a given qualified name. */ @CanIgnoreReturnValue public JavaFileObjectSubject generatedSourceFile(String qualifiedName) { return generatedFile( StandardLocation.SOURCE_OUTPUT, qualifiedName.replaceAll("\\.", "/") + ".java"); }
/** Asserts that compilation generated a source file for a type with a given qualified name. */ @CanIgnoreReturnValue public JavaFileObjectSubject generatedSourceFile(String qualifiedName) { return generatedFile( StandardLocation.SOURCE_OUTPUT, qualifiedName.replaceAll("\\.", "/") + ".java"); }
@CanIgnoreReturnValue @Override public SuccessfulFileClause<T> generatesFileNamed( JavaFileManager.Location location, String packageName, String relativeName) { final JavaFileObjectSubject javaFileObjectSubject = check() .about(compilations()) .that(compilation) .generatedFile(location, packageName, relativeName); return new SuccessfulFileClause<T>() { @Override public GeneratedPredicateClause<T> and() { return GeneratedCompilationBuilder.this; } @Override public SuccessfulFileClause<T> withContents(ByteSource expectedByteSource) { javaFileObjectSubject.hasContents(expectedByteSource); return this; } @Override public SuccessfulFileClause<T> withStringContents(Charset charset, String expectedString) { javaFileObjectSubject.contentsAsString(charset).isEqualTo(expectedString); return this; } }; }
@CanIgnoreReturnValue @Override public SuccessfulFileClause<T> generatesFileNamed( JavaFileManager.Location location, String packageName, String relativeName) { final JavaFileObjectSubject javaFileObjectSubject = check() .about(compilations()) .that(compilation) .generatedFile(location, packageName, relativeName); return new SuccessfulFileClause<T>() { @Override public GeneratedPredicateClause<T> and() { return GeneratedCompilationBuilder.this; } @Override public SuccessfulFileClause<T> withContents(ByteSource expectedByteSource) { javaFileObjectSubject.hasContents(expectedByteSource); return this; } @Override public SuccessfulFileClause<T> withStringContents(Charset charset, String expectedString) { javaFileObjectSubject.contentsAsString(charset).isEqualTo(expectedString); return this; } }; }