public class Subject<S extends Subject<S,T>,T> extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Subject.HasField |
Modifier and Type | Field and Description |
---|---|
protected FailureStrategy |
failureStrategy |
Constructor and Description |
---|
Subject(FailureStrategy failureStrategy,
T subject) |
Modifier and Type | Method and Description |
---|---|
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.
|
protected final FailureStrategy failureStrategy
public Subject(FailureStrategy failureStrategy, T subject)
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)
@Deprecated public int hashCode()
Copyright © 2016. All rights reserved.