Class JavaFileObjectSubject

java.lang.Object
com.google.common.truth.Subject<JavaFileObjectSubject, JavaFileObject>
com.google.testing.compile.JavaFileObjectSubject

public final class JavaFileObjectSubject extends com.google.common.truth.Subject<JavaFileObjectSubject, JavaFileObject>
Assertions about JavaFileObjects.
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.google.common.truth.Subject

    com.google.common.truth.Subject.Factory<SubjectT,ActualT>
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
     
    assertThat(@Nullable JavaFileObject actual)
    Starts making assertions about a JavaFileObject.
    void
    Asserts that the every node in the AST of expectedPattern exists in the actual file's AST, in the same order.
    com.google.common.truth.StringSubject
    Returns a StringSubject that makes assertions about the contents of the actual file as a string.
    com.google.common.truth.StringSubject
    Returns a StringSubject that makes assertions about the contents of the actual file as a UTF-8 string.
    void
    hasContents(com.google.common.io.ByteSource expected)
    Asserts that the actual file's contents are equal to expected.
    void
    Asserts that the actual file is a source file that has an equivalent AST to that of expectedSource.
    void
    isEqualTo(@Nullable Object other)
    If other is a JavaFileObject, tests that their contents are equal.
    static com.google.common.truth.Subject.Factory<JavaFileObjectSubject, JavaFileObject>
    Returns a Subject.Factory for JavaFileObjectSubjects.

    Methods inherited from class com.google.common.truth.Subject

    actual, actualAsString, check, equals, fail, fail, fail, failComparing, failComparing, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutSubject, failWithRawMessage, failWithRawMessageAndCause, getDisplaySubject, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, named

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • javaFileObjects

      public static com.google.common.truth.Subject.Factory<JavaFileObjectSubject, JavaFileObject> javaFileObjects()
      Returns a Subject.Factory for JavaFileObjectSubjects.
    • assertThat

      public static JavaFileObjectSubject assertThat(@Nullable JavaFileObject actual)
      Starts making assertions about a JavaFileObject.
    • actualCustomStringRepresentation

      protected String actualCustomStringRepresentation()
      Overrides:
      actualCustomStringRepresentation in class com.google.common.truth.Subject<JavaFileObjectSubject, JavaFileObject>
    • isEqualTo

      public void isEqualTo(@Nullable Object other)
      If other is a JavaFileObject, tests that their contents are equal. Otherwise uses Object.equals(Object).
      Overrides:
      isEqualTo in class com.google.common.truth.Subject<JavaFileObjectSubject, JavaFileObject>
    • hasContents

      public void hasContents(com.google.common.io.ByteSource expected)
      Asserts that the actual file's contents are equal to expected.
    • contentsAsString

      public com.google.common.truth.StringSubject contentsAsString(Charset charset)
      Returns a StringSubject that makes assertions about the contents of the actual file as a string.
    • contentsAsUtf8String

      public com.google.common.truth.StringSubject contentsAsUtf8String()
      Returns a StringSubject that makes assertions about the contents of the actual file as a UTF-8 string.
    • hasSourceEquivalentTo

      public void hasSourceEquivalentTo(JavaFileObject expectedSource)
      Asserts that the actual file is a source file that has an equivalent AST to that of expectedSource.
    • containsElementsIn

      public void containsElementsIn(JavaFileObject expectedPattern)
      Asserts that the every node in the AST of expectedPattern exists in the actual file's AST, in the same order.

      Methods, constructors, fields, and types that are in the pattern must have the exact same modifiers and annotations as the actual AST. Ordering of AST nodes is also important (i.e. a type with identical members in a different order will fail the assertion). Types must match the entire type declaration: type parameters, extends/implements clauses, etc. Methods must also match the throws clause as well.

      The body of a method or constructor, or field initializer in the actual AST must match the pattern in entirety if the member is present in the pattern.

      Said in another way (from a graph-theoretic perspective): the pattern AST must be a subgraph of the actual AST. If a method, constructor, or field is in the pattern, that entire subtree, including modifiers and annotations, must be equal to the corresponding subtree in the actual AST (no proper subgraphs).