Tabnine Logo
JavaFileObjects.forSourceString
Code IndexAdd Tabnine to your IDE (free)

How to use
forSourceString
method
in
com.google.testing.compile.JavaFileObjects

Best Java code snippets using com.google.testing.compile.JavaFileObjects.forSourceString (Showing top 20 results out of 378)

origin: JakeWharton/butterknife

@Test public void textChangedWithWrongParameter() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
     + "package test;\n"
     + "import butterknife.OnTextChanged;\n"
     + "public class Test {\n"
     + "  @OnTextChanged(1) void doStuff(String p0, int p1, int p2, int p3) {}\n"
     + "}"
 );
 assertAbout(javaSource()).that(source)
     .withCompilerOptions("-Xlint:-processing")
     .processedWith(new ButterKnifeProcessor())
     .failsToCompile();
}
origin: JakeWharton/butterknife

@Test public void typeMustBeTypeface() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import butterknife.BindFont;\n"
   + "public class Test {\n"
   + "  @BindFont(1) String one;\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining("@BindFont field type must be 'Typeface'. (test.Test.one)")
   .in(source).onLine(4);
}
origin: JakeWharton/butterknife

@Test public void failsWithInvalidId() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import butterknife.OnItemClick;\n"
   + "public class Test {\n"
   + "  @OnItemClick({1, -1}) void doStuff() {}\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining("@OnItemClick annotation contains invalid ID -1. (test.Test.doStuff)")
   .in(source).onLine(4);
}
origin: JakeWharton/butterknife

@Test public void failsIfArrayNotView() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import butterknife.BindViews;\n"
   + "public class Test {\n"
   + "  @BindViews(1) String[] thing;\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining(
     "@BindViews List or array type must extend from View or be an interface. (test.Test.thing)")
   .in(source).onLine(4);
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeBoolean() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindBool;\n"
    + "public class Test {\n"
    + "  @BindBool(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindBool field type must be 'boolean'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeAnimation() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindAnim;\n"
    + "public class Test {\n"
    + "  @BindAnim(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindAnim field type must be 'Animation'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeDrawable() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindDrawable;\n"
    + "public class Test {\n"
    + "  @BindDrawable(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindDrawable field type must be 'Drawable'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

@Test public void failsInAndroidPackage() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package android.test;\n"
   + "import butterknife.OnClick;\n"
   + "public class Test {\n"
   + "  @OnClick(1) void doStuff() {}\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining(
     "@OnClick-annotated class incorrectly in Android framework package. (android.test.Test)")
   .in(source).onLine(4);
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeBitmap() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindBitmap;\n"
    + "public class Test {\n"
    + "  @BindBitmap(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindBitmap field type must be 'Bitmap'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

@Test public void failsIfNoGenericType() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import butterknife.BindViews;\n"
   + "import java.util.List;\n"
   + "public class Test {\n"
   + "  @BindViews(1) List thing;\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining("@BindViews List must have a generic component. (test.Test.thing)")
   .in(source).onLine(5);
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeIntOrColorStateList() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindColor;\n"
    + "public class Test {\n"
    + "  @BindColor(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindColor field type must be 'int' or 'ColorStateList'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeString() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindString;\n"
    + "public class Test {\n"
    + "  @BindString(1) boolean one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindString field type must be 'String'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

@Test public void failsInJavaPackage() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package java.test;\n"
   + "import butterknife.OnClick;\n"
   + "public class Test {\n"
   + "  @OnClick(1) void doStuff() {}\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining(
     "@OnClick-annotated class incorrectly in Java framework package. (java.test.Test)")
   .in(source).onLine(4);
}
origin: JakeWharton/butterknife

@Test public void failsIfNotView() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import butterknife.BindView;\n"
   + "public class Test {\n"
   + "  @BindView(1) String thing;\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining(
     "@BindView fields must extend from View or be an interface. (test.Test.thing)")
   .in(source).onLine(4);
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeIntOrFloat() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindDimen;\n"
    + "public class Test {\n"
    + "  @BindDimen(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindDimen field type must be 'int' or 'float'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeFloat() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindFloat;\n"
    + "public class Test {\n"
    + "  @BindFloat(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindFloat field type must be 'float'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

@Test public void failsIfPrivate() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import android.view.View;\n"
   + "import butterknife.BindView;\n"
   + "public class Test {\n"
   + "    @BindView(1) private View thing;\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining("@BindView fields must not be private or static. (test.Test.thing)")
   .in(source).onLine(5);
}
origin: JakeWharton/butterknife

@Test public void failsIfStatic() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import android.view.View;\n"
   + "import butterknife.BindView;\n"
   + "public class Test {\n"
   + "    @BindView(1) static View thing;\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining("@BindView fields must not be private or static. (test.Test.thing)")
   .in(source).onLine(5);
}
origin: JakeWharton/butterknife

 @Test public void typeMustBeInt() {
  JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
    + "package test;\n"
    + "import butterknife.BindInt;\n"
    + "public class Test {\n"
    + "  @BindInt(1) String one;\n"
    + "}"
  );

  assertAbout(javaSource()).that(source)
    .processedWith(new ButterKnifeProcessor())
    .failsToCompile()
    .withErrorContaining("@BindInt field type must be 'int'. (test.Test.one)")
    .in(source).onLine(4);
 }
}
origin: JakeWharton/butterknife

@Test public void failsIfInInterface() {
 JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
   + "package test;\n"
   + "import android.view.View;\n"
   + "import butterknife.BindView;\n"
   + "public interface Test {\n"
   + "    @BindView(1) View thing = null;\n"
   + "}"
 );
 assertAbout(javaSource()).that(source)
   .processedWith(new ButterKnifeProcessor())
   .failsToCompile()
   .withErrorContaining(
     "@BindView fields may only be contained in classes. (test.Test.thing)")
   .in(source).onLine(4);
}
com.google.testing.compileJavaFileObjectsforSourceString

Javadoc

Creates a JavaFileObject with a path corresponding to the fullyQualifiedNamecontaining the give source. The returned object will always be read-only and have the Kind#SOURCE JavaFileObject#getKind().

Note that this method makes no attempt to verify that the name matches the contents of the source and compilation errors may result if they do not match.

Popular methods of JavaFileObjects

  • forResource
    Returns a JavaFileObject for the resource at the given URL. The returned object will always be read-
  • forSourceLines
    Behaves exactly like #forSourceString, but joins lines so that multi-line source strings may omit th
  • asByteSource
  • deduceKind

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JLabel (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now