Class JavaFileObjectSubject
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 TypeMethodDescriptionprotected Stringstatic JavaFileObjectSubjectassertThat(@Nullable JavaFileObject actual) Starts making assertions about aJavaFileObject.voidcontainsElementsIn(JavaFileObject expectedPattern) Asserts that the every node in the AST ofexpectedPatternexists in the actual file's AST, in the same order.com.google.common.truth.StringSubjectcontentsAsString(Charset charset) Returns aStringSubjectthat makes assertions about the contents of the actual file as a string.com.google.common.truth.StringSubjectReturns aStringSubjectthat makes assertions about the contents of the actual file as a UTF-8 string.voidhasContents(com.google.common.io.ByteSource expected) Asserts that the actual file's contents are equal toexpected.voidhasSourceEquivalentTo(JavaFileObject expectedSource) Asserts that the actual file is a source file that has an equivalent AST to that ofexpectedSource.voidIfotheris aJavaFileObject, tests that their contents are equal.static com.google.common.truth.Subject.Factory<JavaFileObjectSubject, JavaFileObject> Returns aSubject.FactoryforJavaFileObjectSubjects.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
-
Method Details
-
javaFileObjects
public static com.google.common.truth.Subject.Factory<JavaFileObjectSubject, JavaFileObject> javaFileObjects()Returns aSubject.FactoryforJavaFileObjectSubjects. -
assertThat
Starts making assertions about aJavaFileObject. -
actualCustomStringRepresentation
- Overrides:
actualCustomStringRepresentationin classcom.google.common.truth.Subject<JavaFileObjectSubject, JavaFileObject>
-
isEqualTo
Ifotheris aJavaFileObject, tests that their contents are equal. Otherwise usesObject.equals(Object).- Overrides:
isEqualToin classcom.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 toexpected. -
contentsAsString
Returns aStringSubjectthat makes assertions about the contents of the actual file as a string. -
contentsAsUtf8String
public com.google.common.truth.StringSubject contentsAsUtf8String()Returns aStringSubjectthat makes assertions about the contents of the actual file as a UTF-8 string. -
hasSourceEquivalentTo
Asserts that the actual file is a source file that has an equivalent AST to that ofexpectedSource. -
containsElementsIn
Asserts that the every node in the AST ofexpectedPatternexists 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/implementsclauses, 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).
-