Class Subject<S extends Subject<S,T> , T>
java.lang.Object
com.google.common.truth.Subject<S,T>
- Direct Known Subclasses:
AbstractArraySubject, ClassSubject, ComparableSubject, DefaultSubject, IterableSubject, MapSubject, OptionalSubject, Subject
Propositions for arbitrarily typed subjects and for properties
of Object
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TestVerbcheck()A convenience for implementers ofSubjectsubclasses to use other truthSubjectwrappers within their own propositional logic.booleanDeprecated.This method is not a proposition, but the default Object equality method.protected voidAssembles a failure message and passes such to the FailureStrategyprotected voidAssembles a failure message and passes such to the FailureStrategy.protected voidAssembles a failure message and passes such to the FailureStrategyprotected voidfailWithBadResults(String verb, Object expected, String failVerb, Object actual) Assembles a failure message and passes it to the FailureStrategyprotected voidfailWithCustomSubject(String verb, Object expected, Object actual) Assembles a failure message with an alternative representation of the wrapped subject and passes it to the FailureStrategyprotected voidfailWithoutSubject(String verb) Assembles a failure message without a given subject and passes it to the FailureStrategyprotected voidfailWithRawMessage(String message, Object... parameters) Passes through a failure message verbatim.protected Stringprotected TinthashCode()Deprecated.Equals/Hashcode is not supported on Subjects.protected StringvoidDeprecated.UseisEqualTo(Object)to check object equality orisSameAs(Object)to check reference equality.voidDeprecated.UseisInstanceOf(Class)instead.voidFails if the subject is not equal to the given object.voidisInstanceOf(Class<?> clazz) Fails if the subject is not an instance of the given class.voidDeprecated.UseisNotInstanceOf(Class)instead.voidisNotEqualTo(Object other) Fails if the subject is equal to the given object.voidisNotInstanceOf(Class<?> clazz) Fails if the subject is an instance of the given class.voidFails if the subject is null.voidisNotSameAs(Object other) Fails if the subject is the same instance as the given object.voidisNull()Fails if the subject is not null.voidFails if the subject is not the same instance as the given object.Deprecated.Usenamed(String)instead.Renames the subject so that this name appears in the error messages in place of string representations of the subject.
-
Field Details
-
failureStrategy
-
subject
-
customName
-
-
Constructor Details
-
Subject
-
-
Method Details
-
internalCustomName
-
named
-
labeled
Deprecated.Usenamed(String)instead. -
is
Deprecated.UseisEqualTo(Object)to check object equality orisSameAs(Object)to check reference equality. -
isNull
public void isNull()Fails if the subject is not null. -
isNotNull
public void isNotNull()Fails if the subject is null. -
isEqualTo
Fails if the subject is not equal to the given object. -
isNotEqualTo
Fails if the subject is equal to the given object. -
isSameAs
Fails if the subject is not the same instance as the given object. -
isNotSameAs
Fails if the subject is the same instance as the given object. -
isA
Deprecated.UseisInstanceOf(Class)instead.Fails if the subject is not an instance of the given class. -
isNotA
Deprecated.UseisNotInstanceOf(Class)instead.Fails if the subject is an instance of the given class. -
isInstanceOf
Fails if the subject is not an instance of the given class. -
isNotInstanceOf
Fails if the subject is an instance of the given class. -
getSubject
-
getDisplaySubject
-
check
-
fail
Assembles a failure message and passes such to the FailureStrategy- Parameters:
verb- the proposition being asserted
-
fail
-
fail
-
failWithBadResults
-
failWithCustomSubject
Assembles a failure message with an alternative representation of the wrapped subject and passes it to the FailureStrategy- Parameters:
verb- the proposition being assertedexpected- the expected value of the propositionactual- the custom representation of the subject to be reported in the failure.
-
failWithoutSubject
Assembles a failure message without a given subject and passes it to the FailureStrategy- Parameters:
verb- the proposition being asserted
-
failWithRawMessage
Passes through a failure message verbatim. Used forSubjectsubclasses which need to provide alternate language for more fit-to-purpose error messages.- Parameters:
message- the message template to be passed to the failure. Note, this method only guarantees to process%stokens. It is not guaranteed to be compatible withString.format(). Any other formatting desired (such as floats or scientific notation) should be performed before the method call and the formatted value passed in as a string.paramters- the object parameters which will be applied to the message template.
-
hasField
-
equals
Deprecated.This method is not a proposition, but the default Object equality method. Testing code should use "is" or "isEqualTo" propositions for equality tests. -
hashCode
Deprecated.Equals/Hashcode is not supported on Subjects. Their only use is as a holder of propositions. Use of equals() is deprecated and forwards to isEqualTo() and hashCode() is disallowed.
-