• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JavaSourcesSubjectFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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));
}
 
开发者ID:Cosium,项目名称:openapi-annotation-processor,代码行数:24,代码来源:ParserCaseTester.java


示例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")
            );
}
 
开发者ID:DanielSerdyukov,项目名称:alchemy,代码行数:23,代码来源:SQLiteCompilerTest.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();
}
 
开发者ID:egopulse,项目名称:java-code-gen,代码行数:18,代码来源:TestModels.java


示例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"));
}
 
开发者ID:orekyuu,项目名称:Moco,代码行数:11,代码来源:EntityProcessorTest.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);
}
 
开发者ID:RoRoche,项目名称:AnnotationProcessorStarter,代码行数:14,代码来源:MyProcessorTest.java


示例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 );
}
 
开发者ID:arez,项目名称:arez,代码行数:37,代码来源:AbstractArezProcessorTest.java


示例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();

}
 
开发者ID:doanduyhai,项目名称:annotation_processing_demo,代码行数:8,代码来源:AbstractTestProcessor.java


示例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);
}
 
开发者ID:doanduyhai,项目名称:annotation_processing_demo,代码行数:8,代码来源:AbstractTestProcessor.java


示例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());
}
 
开发者ID:inloop,项目名称:Knight,代码行数:10,代码来源:BaseTest.java


示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:CompilerTest.java


示例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 );
}
 
开发者ID:react4j,项目名称:react4j,代码行数:43,代码来源:AbstractReactProcessorTest.java


示例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());
}
 
开发者ID:lesaint,项目名称:damapping,代码行数:6,代码来源:AbstractCompilationTest.java



注:本文中的com.google.testing.compile.JavaSourcesSubjectFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PendingCallStore类代码示例发布时间:2022-05-22
下一篇:
Java NodeStats类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap