本文整理汇总了Java中com.google.testing.compile.JavaSourcesSubjectFactory类的典型用法代码示例。如果您正苦于以下问题:Java JavaSourcesSubjectFactory类的具体用法?Java JavaSourcesSubjectFactory怎么用?Java JavaSourcesSubjectFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaSourcesSubjectFactory类属于com.google.testing.compile包,在下文中一共展示了JavaSourcesSubjectFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
private void doTest() throws Exception {
LOG.info("Running test '{}' for parser '{}'", caseName, parserName);
List<JavaFileObject> inputs = subFileObjetcs(inputPath);
LOG.debug("Using inputs {}", inputs);
List<String> options = parseOptions();
LOG.debug("Using options {}", options);
CompileTester.SuccessfulCompilationClause clause = Truth.assert_()
.about(JavaSourcesSubjectFactory.javaSources())
.that(subFileObjetcs(inputPath))
.withCompilerOptions(options)
.processedWith(new OpenAPIProcessor())
.compilesWithoutError();
resources(expectedPath)
.stream()
.peek(resource -> LOG.debug("Validating expectation on {}", resource))
.forEach(resource -> clause.and()
.generatesFileNamed(LOCATION, resource.packageName, resource.relativeName)
.withContents(resource.byteSource));
}
示例2: generatedFiles
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
@Test
public void generatedFiles() throws Exception {
Truth.assertAbout(JavaSourcesSubjectFactory.javaSources())
.that(Arrays.asList(
JavaFileObjects.forResource("models/groups/Group.java"),
JavaFileObjects.forResource("models/users/User.java")
))
.processedWith(new SQLiteCompiler())
.compilesWithoutError()
.and()
.generatesSources(
JavaFileObjects.forResource("generated/alchemy/sqlite/DefaultSchema.java"),
JavaFileObjects.forResource("generated/alchemy/sqlite/Group_Table.java"),
JavaFileObjects.forResource("generated/alchemy/sqlite/User_Table.java"),
JavaFileObjects.forResource("generated/models/groups/Group_Entry.java"),
JavaFileObjects.forResource("generated/models/groups/Group_Admin.java"),
JavaFileObjects.forResource("generated/models/groups/Group_Users.java"),
JavaFileObjects.forResource("generated/models/groups/GroupContract.java"),
JavaFileObjects.forResource("generated/models/users/User_Entry.java"),
JavaFileObjects.forResource("generated/models/users/UserContract.java")
);
}
示例3: testGenericList
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
@Test
public void testGenericList() throws Exception
{
Truth.assert_().about(JavaSourcesSubjectFactory.javaSources())
.that(Collections.singletonList(JavaFileObjects.forResource("com/egopulse/gen/TestGenericList.java")))
.processedWith(new TestProcessor((elem, models) -> {
List<VariableElement> fields = models.getFields(elem);
Assert.assertEquals("Number of fields", 1, fields.size());
VariableElement listField = fields.get(0);
Assert.assertTrue("Is generic list ", models.isGenericList(listField.asType()));
List<ExecutableElement> methods = models.getMethods(elem);
Assert.assertEquals("Number of methods", 1, methods.size());
ExecutableElement listMethod = methods.get(0);
Assert.assertTrue("Is generic list ", models.isGenericList(listMethod.getReturnType()));
}))
.compilesWithoutError();
}
示例4: testEntityProcessor
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
@Test
public void testEntityProcessor() {
Truth.assert_()
.about(JavaSourcesSubjectFactory.javaSources())
.that(Arrays.asList(JavaFileObjects.forResource("example/User.java")))
.processedWith(new EntityProcessor())
.compilesWithoutError()
.and()
.generatesSources(JavaFileObjects.forResource("expected/Users.java"));
}
示例5: process_A_with_annotated_method
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
@Test
public void process_A_with_annotated_method() throws IOException {
final JavaFileObject lInput = JavaFileObjects.forResource("assets/A.java");
final JavaFileObject lOutput = JavaFileObjects.forResource("assets/A$$MyAnnotation.java");
assert_()
.about(JavaSourcesSubjectFactory.javaSources())
.that(Arrays.asList(lInput))
.processedWith(new MyProcessor())
.compilesWithoutError()
.and()
.generatesSources(lOutput);
}
示例6: assertSuccessfulCompile
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
void assertSuccessfulCompile( @Nonnull final List<JavaFileObject> inputs,
@Nonnull final List<String> outputs )
throws Exception
{
if ( outputFiles() )
{
final ImmutableList<JavaFileObject> fileObjects =
Compiler.javac().withProcessors( new ArezProcessor() ).compile( inputs ).generatedSourceFiles();
for ( final JavaFileObject fileObject : fileObjects )
{
final Path target = fixtureDir().resolve( "expected/" + fileObject.getName().replace( "/SOURCE_OUTPUT/", "" ) );
if ( Files.exists( target ) )
{
Files.delete( target );
}
final File dir = target.getParent().toFile();
if ( !dir.exists() )
{
assertTrue( dir.mkdirs() );
}
Files.copy( fileObject.openInputStream(), target );
}
}
final JavaFileObject firstExpected = fixture( outputs.get( 0 ) );
final JavaFileObject[] restExpected =
outputs.stream().skip( 1 ).map( this::fixture ).
collect( Collectors.toList() ).
toArray( new JavaFileObject[ 0 ] );
assert_().about( JavaSourcesSubjectFactory.javaSources() ).
that( inputs ).
processedWith( new ArezProcessor() ).
compilesWithoutError().
and().
generatesSources( firstExpected, restExpected );
}
示例7: launchTest
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
protected void launchTest(Class<?> testClass) {
assert_().about(JavaSourcesSubjectFactory.javaSources())
.that(Arrays.asList(loadClass(testClass)))
.processedWith(this)
.compilesWithoutError();
}
示例8: failTestWithMessage
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
protected void failTestWithMessage(String message, Class<?> testClass) {
assert_().about(JavaSourcesSubjectFactory.javaSources())
.that(Arrays.asList(loadClass(testClass)))
.processedWith(this)
.failsToCompile()
.withErrorContaining(message);
}
示例9: assertFiles
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
protected CompileTester assertFiles(JavaFileObject... f) {
List<JavaFileObject> files = new ArrayList<>();
files.addAll(Arrays.asList(f));
return Truth.assert_()
.about(JavaSourcesSubjectFactory.javaSources())
.that(files)
.processedWith(new ComponentProcessor(), new KnightProcessor());
}
示例10: getThat
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
protected CompileTester getThat(Collection<? extends Processor> processors, final JavaFileObject... target) {
return Truth.assert_().about(JavaSourcesSubjectFactory.javaSources())
.that(Arrays.asList(target))
.processedWith(processors);
}
示例11: assertSuccessfulCompile
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
void assertSuccessfulCompile( @Nonnull final List<JavaFileObject> inputs, @Nonnull final List<String> outputs )
throws Exception
{
// Arez processor required so that our tests emit all the right outputs
// when outputFiles() is true
if ( outputFiles() )
{
final ImmutableList<JavaFileObject> fileObjects =
Compiler.javac().withProcessors( new ReactProcessor(), new ArezProcessor() ).
compile( inputs ).generatedSourceFiles();
for ( final JavaFileObject fileObject : fileObjects )
{
final Path target = fixtureDir().resolve( "expected/" + fileObject.getName().replace( "/SOURCE_OUTPUT/", "" ) );
if ( target.toFile().getName().startsWith( "Arez_" ) )
{
continue;
}
if ( Files.exists( target ) )
{
Files.delete( target );
}
final File dir = target.getParent().toFile();
if ( !dir.exists() )
{
assertTrue( dir.mkdirs() );
}
Files.copy( fileObject.openInputStream(), target );
}
}
final JavaFileObject firstExpected = fixture( outputs.get( 0 ) );
final JavaFileObject[] restExpected =
outputs.stream().skip( 1 ).map( this::fixture ).
collect( Collectors.toList() ).
toArray( new JavaFileObject[ 0 ] );
assert_().about( JavaSourcesSubjectFactory.javaSources() ).
that( inputs ).
processedWith( new ReactProcessor(), new ArezProcessor() ).
compilesWithoutError().
and().
generatesSources( firstExpected, restExpected );
}
示例12: assertThat
import com.google.testing.compile.JavaSourcesSubjectFactory; //导入依赖的package包/类
protected CompileTester assertThat(JavaFileObject... fileObjects) {
return Truth.ASSERT.about(JavaSourcesSubjectFactory.javaSources())
.that(Arrays.asList(fileObjects))
.processedWith(new DAAnnotationProcessor());
}