|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.truth.Subject<S,T>
public class Subject<S extends Subject<S,T>,T>
Propositions for arbitrarily typed subjects and for properties of Object
Nested Class Summary | |
---|---|
static interface |
Subject.HasField
|
Field Summary | |
---|---|
protected FailureStrategy |
failureStrategy
|
Constructor Summary | |
---|---|
Subject(FailureStrategy failureStrategy,
T subject)
|
Method Summary | |
---|---|
protected TestVerb |
check()
A convenience for implementers of Subject subclasses to use other truth
Subject wrappers within their own propositional logic. |
boolean |
equals(Object o)
Deprecated. This method is not a proposition, but the default Object equality method. Testing code should use "is" or "isEqualTo" propositions for equality tests. |
protected void |
fail(String verb,
Object... messageParts)
Assembles a failure message and passes such to the FailureStrategy |
protected void |
failWithBadResults(String verb,
Object expected,
String failVerb,
Object actual)
Assembles a failure message and passes it to the FailureStrategy |
protected void |
failWithCustomSubject(String verb,
Object expected,
Object actual)
Assembles a failure message with an alternative representation of the wrapped subject and passes it to the FailureStrategy |
protected void |
failWithoutSubject(String verb)
Assembles a failure message without a given subject and passes it to the FailureStrategy |
protected void |
failWithRawMessage(String message,
Object... parameters)
Passes through a failure message verbatim. |
protected String |
getDisplaySubject()
|
protected T |
getSubject()
|
Subject.HasField |
hasField(String fieldName)
|
int |
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. |
protected String |
internalCustomName()
|
void |
is(Object other)
|
void |
isA(Class<?> clazz)
|
void |
isEqualTo(Object other)
|
void |
isNotA(Class<?> clazz)
|
void |
isNotEqualTo(Object other)
|
void |
isNotNull()
|
void |
isNull()
|
S |
labeled(String label)
Soft-deprecated in favor of named(String) . |
S |
named(String name)
Renames the subject so that this name appears in the error messages in place of string representations of the subject. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final FailureStrategy failureStrategy
Constructor Detail |
---|
public Subject(FailureStrategy failureStrategy, T subject)
Method Detail |
---|
protected String internalCustomName()
public S named(String name)
public S labeled(String label)
named(String)
.
public void is(Object other)
public void isNull()
public void isNotNull()
public void isEqualTo(Object other)
public void isNotEqualTo(Object other)
public void isA(Class<?> clazz)
public void isNotA(Class<?> clazz)
protected T getSubject()
protected String getDisplaySubject()
protected TestVerb check()
Subject
subclasses to use other truth
Subject
wrappers within their own propositional logic.
protected void fail(String verb, Object... messageParts)
verb
- the proposition being assertedmessageParts
- the expectations against which the subject is comparedprotected void failWithBadResults(String verb, Object expected, String failVerb, Object actual)
verb
- the proposition being assertedmessageParts
- the expectations against which the subject is comparedprotected void failWithCustomSubject(String verb, Object expected, Object actual)
verb
- the proposition being assertedexpected
- the expected value of the propositionactual
- the custom representation of the subject to be reported in the failure.protected void failWithoutSubject(String verb)
verb
- the proposition being assertedprotected void failWithRawMessage(String message, Object... parameters)
Subject
subclasses which
need to provide alternate language for more fit-to-purpose error messages.
message
- the message template to be passed to the failure. Note, this method only
guarantees to process %s
tokens. It is not guaranteed to be compatible
with String.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.@GwtIncompatible(value="java.lang.reflect.Field") public Subject.HasField hasField(String fieldName)
@Deprecated public boolean equals(Object o)
equals
in class Object
@Deprecated public int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |