当前位置: 首页>>代码示例>>Java>>正文


Java JavaSourceSubjectFactory类代码示例

本文整理汇总了Java中com.google.testing.compile.JavaSourceSubjectFactory的典型用法代码示例。如果您正苦于以下问题:Java JavaSourceSubjectFactory类的具体用法?Java JavaSourceSubjectFactory怎么用?Java JavaSourceSubjectFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaSourceSubjectFactory类属于com.google.testing.compile包,在下文中一共展示了JavaSourceSubjectFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNRelatedToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testNRelatedToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess() {
  //GIVEN
  JavaFileObject source = forSourceString("test.Test", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test {\n" //
      + "}");

  //WHEN
  //THEN
  //we can't test that no files were generated, but we would need it.
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.") //
      .processedWith(new NRelatedToOneAP()) //
      .compilesWithoutError();
}
 
开发者ID:gradle,项目名称:incap,代码行数:19,代码来源:NRelatedToOneAPTest.java

示例2: testNRelatedToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testNRelatedToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess() {
  //GIVEN
  JavaFileObject source0 = forSourceString("test.Test0", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test0 {\n" //
      + "}\n" //
      + "@Annotation1\n" //
      + "class Test1 extends Test0{\n" //
      + "}");

  JavaFileObject expected10 = forSourceString("NRelatedToOneAP_Test1_Test0Gen0", "" //
      + "\n" //
      + "public class NRelatedToOneAP_Test1_Test0Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source0) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NRelatedToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected10);
}
 
开发者ID:gradle,项目名称:incap,代码行数:26,代码来源:NRelatedToOneAPTest.java

示例3: testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess() {
  //GIVEN
  JavaFileObject source = forSourceString("test.Test", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.") //
      .processedWith(new NUnrelatedANDToOneAP()) //
      .compilesWithoutError();
  //we cannot assert that no file gets generated...
}
 
开发者ID:gradle,项目名称:incap,代码行数:19,代码来源:NUnrelatedANDToOneAPTest.java

示例4: testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testNUnrelatedANDToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess() {
  //GIVEN
  JavaFileObject source0 = forSourceString("test.Test0", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test0 {\n" //
      + "}\n" //
      + "@Annotation1\n" //
      + "class Test1 {\n" //
      + "}");
  JavaFileObject expected = forSourceString("NUnrelatedANDToOneAP_AND_Gen0", "" //
      + "\n" //
      + "public class NUnrelatedANDToOneAP_AND_Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source0) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NUnrelatedANDToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected);
}
 
开发者ID:gradle,项目名称:incap,代码行数:25,代码来源:NUnrelatedANDToOneAPTest.java

示例5: testOneToNAP_creates_GeneratedFiles_WhenSingleFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testOneToNAP_creates_GeneratedFiles_WhenSingleFileToProcess() {
  //GIVEN
  JavaFileObject source = forSourceString("test.Test", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test {\n" //
      + "}");
  JavaFileObject expected0 = forSourceString("OneToNAP_TestGen0", "" //
      + "\n" //
      + "public class OneToNAP_TestGen0 {\n" //
      + "}");

  JavaFileObject expected1 = forSourceString("OneToNAP_TestGen1", "" //
      + "\n" //
      + "public class OneToNAP_TestGen1 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new OneToNAP()) //
      .compilesWithoutError().and().generatesSources(expected0, expected1);
}
 
开发者ID:gradle,项目名称:incap,代码行数:27,代码来源:OneToNAPTest.java

示例6: testOneToOneAP_creates_GeneratedFile_WhenSingleFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testOneToOneAP_creates_GeneratedFile_WhenSingleFileToProcess() {
  //GIVEN
  source = forSourceString("test.Test", "" //
          + "package test;\n" //
          + "import org.gradle.incap.Annotation1;\n" //
          + "@Annotation1\n" //
          + "public class Test {\n" //
          + "}");
  expected = forSourceString("OneToOneAP_TestGen0", "" //
          + "\n" //
          + "public class OneToOneAP_TestGen0 {\n" //
          + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new OneToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected);
}
 
开发者ID:gradle,项目名称:incap,代码行数:22,代码来源:OneToOneAPTest.java

示例7: testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenSingleFileToProcess() {
  //GIVEN
  JavaFileObject source = forSourceString("test.Test", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test {\n" //
      + "}");
  JavaFileObject expected0 = forSourceString("NUnrelatedORToOneAP_OR_Gen0", "" //
      + "\n" //
      + "public class NUnrelatedORToOneAP_OR_Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NUnrelatedORToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected0);
}
 
开发者ID:gradle,项目名称:incap,代码行数:22,代码来源:NUnrelatedORToOneAPTest.java

示例8: testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void testNUnrelatedORToOneAP_creates_GeneratedFiles_WhenTwoFileToProcess() {
  //GIVEN
  JavaFileObject source0 = forSourceString("test.Test0", "" //
      + "package test;\n" //
      + "import org.gradle.incap.Annotation1;\n" //
      + "@Annotation1\n" //
      + "public class Test0 {\n" //
      + "}\n" //
      + "@Annotation1\n" //
      + "class Test1 {\n" //
      + "}");
  JavaFileObject expected = forSourceString("NUnrelatedORToOneAP_OR_Gen0", "" //
      + "\n" //
      + "public class NUnrelatedORToOneAP_OR_Gen0 {\n" //
      + "}");

  //WHEN
  //THEN
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource()).that(source0) //
      .withCompilerOptions("-Xlint:-processing","-Aincap.mapping.folder=.", "-Aincap.incremental=true") //
      .processedWith(new NUnrelatedORToOneAP()) //
      .compilesWithoutError().and().generatesSources(expected);
}
 
开发者ID:gradle,项目名称:incap,代码行数:25,代码来源:NUnrelatedORToOneAPTest.java

示例9: When_Class_With_Interceptor_Has_Not_Mockery_On_Method_Then_Fail_Compilation

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test public void When_Class_With_Interceptor_Has_Not_Mockery_On_Method_Then_Fail_Compilation() throws Exception {
  JavaFileObject source = JavaFileObjects.forSourceString("RestApi", "" +
      "package test;\n"
      +"import io.victoralbertos.mockery.api.built_in_interceptor.Bypass;\n"
      + "import io.victoralbertos.mockery.api.built_in_mockery.Valid;\n"
      + "import java.util.List;\n"
      + "\n"
      + "import static io.victoralbertos.mockery.api.built_in_mockery.Valid.Template.STRING;\n"
      + "\n"
      + "@Bypass\n"
      + "public interface NoMethodMockery {\n"
      + "  List<String> method(@Valid(STRING) String s1);\n"
      + "}");

  assertAbout(JavaSourceSubjectFactory
      .javaSource()).that(source)
      .processedWith(new MockeryProcessor())
      .failsToCompile();
}
 
开发者ID:VictorAlbertos,项目名称:Mockery,代码行数:20,代码来源:MockeryProcessorTest.java

示例10: When_Class_With_Interceptor_Has_Not_Mockery_On_Param_Then_Fail_Compilation

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test public void When_Class_With_Interceptor_Has_Not_Mockery_On_Param_Then_Fail_Compilation() throws Exception {
  JavaFileObject source = JavaFileObjects.forSourceString("RestApi", "" +
      "package test;\n"
      +"import io.victoralbertos.mockery.api.built_in_interceptor.Bypass;\n"
      + "import io.victoralbertos.mockery.api.built_in_mockery.Valid;\n"
      + "import java.util.List;\n"
      + "\n"
      + "import static io.victoralbertos.mockery.api.built_in_mockery.Valid.Template.STRING;\n"
      + "\n"
      + "@Bypass\n"
      + "interface NoParamsMockery {\n"
      + "  @Valid(STRING)\n"
      + "  List<String> method(String s1, Integer[] integers, double d1);\n"
      + "}");

  assertAbout(JavaSourceSubjectFactory
      .javaSource()).that(source)
      .processedWith(new MockeryProcessor())
      .failsToCompile();
}
 
开发者ID:VictorAlbertos,项目名称:Mockery,代码行数:21,代码来源:MockeryProcessorTest.java

示例11: When_Class_Without_Interceptor_Generate_Nothing

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test public void When_Class_Without_Interceptor_Generate_Nothing() throws Exception {
  JavaFileObject source = JavaFileObjects.forSourceString("RestApi", "" +
      "package test;\n"
      +"import io.victoralbertos.mockery.api.built_in_mockery.Valid;\n"
      + "import java.util.List;\n"
      + "\n"
      + "import static io.victoralbertos.mockery.api.built_in_mockery.Valid.Template.STRING;\n"
      + "\n"
      + "interface RestApi {\n"
      + "  @Valid(STRING)\n"
      + "  List<String> method(@Valid(STRING) String email);\n"
      + "\n"
      + "  List<String> method2();\n"
      + "}");

  assertAbout(JavaSourceSubjectFactory
      .javaSource()).that(source)
      .processedWith(new MockeryProcessor())
      .compilesWithoutError();
}
 
开发者ID:VictorAlbertos,项目名称:Mockery,代码行数:21,代码来源:MockeryProcessorTest.java

示例12: should_generate_where_class

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test
public void should_generate_where_class() throws Exception {
    //Given
    setExec((typeUtils, filer, messager) -> {
        final WhereClassGenerator generator = new WhereClassGenerator(filer);
        final TypeElement typeElement = elementUtils.getTypeElement(TestEntity.class.getCanonicalName());
        final List<VariableElement> columns = ElementFilter.fieldsIn(elementUtils.getAllMembers(typeElement))
                .stream()
                .filter(elm -> elm.getAnnotation(Column.class) != null)
                .collect(toList());

        final TypeSpec generateWhereClass = generator.generateWhereClass(typeElement, columns);
        assertThat(generateWhereClass.toString().trim().replaceAll("\n", ""))
                .isEqualTo(readCodeLineFromFile("expected_code/should_generate_where_class.txt"));
    });

    //When
    Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
            .that(loadClass(TestEntity.class))
            .processedWith(this)
            .compilesWithoutError();

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

示例13: noPublicConstructor

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
/**
 * Tests that fields with min default visibility work as expected
 */
@Test public void noPublicConstructor() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PrivateConstructorClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PrivateConstructorClass {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   String foo;",
          "",
          "private PrivateConstructorClass(){}",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("Class test.PrivateConstructorClass has Column annotated fields (incl. super class) and therefore must provide an public empty constructor (zero parameters)");
}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:24,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例14: annotatedInterface

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Ignore
@Test public void annotatedInterface() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.InterfaceNotValid",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public interface InterfaceNotValid {}"
      );

  // TODO wtf? Why this doesn't throw a processing exception? Annotating an interface in real life throws this exception, so what's going wrong here?
  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("test.InterfaceNotValid is annotated with @ObjectMappable but only classes can be annotated with this annotation");

}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:19,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java

示例15: privateField

import com.google.testing.compile.JavaSourceSubjectFactory; //导入依赖的package包/类
@Test public void privateField() {
  JavaFileObject file =
      JavaFileObjects.forSourceLines("test.PrivateFieldClass",
          "package test;",
          "",
          "@"+ ObjectMappable.class.getCanonicalName(),
          "public class PrivateFieldClass {",
          "   @"+ Column.class.getCanonicalName()+"(\"foo\")",
          "   private String foo;",
          "}"
      );

  Truth.assertAbout(JavaSourceSubjectFactory.javaSource())
      .that(file)
      .processedWith(new ObjectMappableProcessor())
      .failsToCompile()
      .withErrorContaining("The field 'foo' in class PrivateFieldClass is private. A corresponding setter method with the name 'setFoo(java.lang.String)' is expected but haven't been found. Please add this setter method, If you have another setter method named differently please annotate your setter method with @Column");

}
 
开发者ID:sockeqwe,项目名称:sqlbrite-dao,代码行数:20,代码来源:ObjectMappableProcessorNotValidAnnotatedClassTest.java


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