public class StandardSubjectBuilder extends Object
withMessage(java.lang.String)
.
Subject
to create with about(Subject.Factory)
.
Subject
built into Truth, directly specify the value under test
with that(Object)
.
For more information about the methods in this class, see this FAQ entry.
You won't extend this type. When you write a custom subject, see our doc on extensions.
Modifier and Type | Method and Description |
---|---|
<CustomSubjectBuilderT extends CustomSubjectBuilder> |
about(CustomSubjectBuilder.Factory<CustomSubjectBuilderT> factory) |
<S extends Subject<S,A>,A> |
about(Subject.Factory<S,A> factory)
Given a factory for some
Subject class, returns a builder whose that(actual)
method creates instances of that class. |
void |
fail()
Triggers the failure strategy with an empty failure message
|
void |
fail(String format,
Object... args)
Triggers the failure strategy with the given failure message
|
static StandardSubjectBuilder |
forCustomFailureStrategy(FailureStrategy failureStrategy)
Returns a new instance that invokes the given
FailureStrategy when a check fails. |
AtomicLongMapSubject |
that(AtomicLongMap<?> actual) |
BigDecimalSubject |
that(BigDecimal actual) |
BooleanSubject |
that(Boolean actual) |
PrimitiveBooleanArraySubject |
that(boolean[] actual) |
PrimitiveByteArraySubject |
that(byte[] actual) |
PrimitiveCharArraySubject |
that(char[] actual) |
ClassSubject |
that(Class<?> actual) |
<ComparableT extends Comparable<?>> |
that(ComparableT actual) |
DoubleSubject |
that(Double actual) |
PrimitiveDoubleArraySubject |
that(double[] actual) |
FloatSubject |
that(Float actual) |
PrimitiveFloatArraySubject |
that(float[] actual) |
PrimitiveIntArraySubject |
that(int[] actual) |
IntegerSubject |
that(Integer actual) |
IterableSubject |
that(Iterable<?> actual) |
ListMultimapSubject |
that(ListMultimap<?,?> actual) |
LongSubject |
that(Long actual) |
PrimitiveLongArraySubject |
that(long[] actual) |
MapSubject |
that(Map<?,?> actual) |
MultimapSubject |
that(Multimap<?,?> actual) |
MultisetSubject |
that(Multiset<?> actual) |
Subject<DefaultSubject,Object> |
that(Object actual) |
GuavaOptionalSubject |
that(Optional<?> actual) |
SetMultimapSubject |
that(SetMultimap<?,?> actual) |
PrimitiveShortArraySubject |
that(short[] actual) |
SortedMapSubject |
that(SortedMap<?,?> actual) |
SortedSetSubject |
that(SortedSet<?> actual) |
StringSubject |
that(String actual) |
<T> ObjectArraySubject<T> |
that(T[] actual) |
TableSubject |
that(Table<?,?,?> actual) |
ThrowableSubject |
that(Throwable actual) |
StandardSubjectBuilder |
withMessage(String messageToPrepend) |
StandardSubjectBuilder |
withMessage(String format,
Object... args)
Returns a new instance that will output the given message before the main failure message.
|
public static StandardSubjectBuilder forCustomFailureStrategy(FailureStrategy failureStrategy)
FailureStrategy
when a check fails. Most
users should not need this. If you think you do, see the documentation on FailureStrategy
.public final <ComparableT extends Comparable<?>> ComparableSubject<?,ComparableT> that(@NullableDecl ComparableT actual)
public final BigDecimalSubject that(@NullableDecl BigDecimal actual)
public final Subject<DefaultSubject,Object> that(@NullableDecl Object actual)
@GwtIncompatible(value="ClassSubject.java") public final ClassSubject that(@NullableDecl Class<?> actual)
public final ThrowableSubject that(@NullableDecl Throwable actual)
public final LongSubject that(@NullableDecl Long actual)
public final DoubleSubject that(@NullableDecl Double actual)
public final FloatSubject that(@NullableDecl Float actual)
public final IntegerSubject that(@NullableDecl Integer actual)
public final BooleanSubject that(@NullableDecl Boolean actual)
public final StringSubject that(@NullableDecl String actual)
public final IterableSubject that(@NullableDecl Iterable<?> actual)
public final SortedSetSubject that(@NullableDecl SortedSet<?> actual)
public final <T> ObjectArraySubject<T> that(@NullableDecl T[] actual)
public final PrimitiveBooleanArraySubject that(@NullableDecl boolean[] actual)
public final PrimitiveShortArraySubject that(@NullableDecl short[] actual)
public final PrimitiveIntArraySubject that(@NullableDecl int[] actual)
public final PrimitiveLongArraySubject that(@NullableDecl long[] actual)
public final PrimitiveCharArraySubject that(@NullableDecl char[] actual)
public final PrimitiveByteArraySubject that(@NullableDecl byte[] actual)
public final PrimitiveFloatArraySubject that(@NullableDecl float[] actual)
public final PrimitiveDoubleArraySubject that(@NullableDecl double[] actual)
public final GuavaOptionalSubject that(@NullableDecl Optional<?> actual)
public final MapSubject that(@NullableDecl Map<?,?> actual)
public final SortedMapSubject that(@NullableDecl SortedMap<?,?> actual)
public final MultimapSubject that(@NullableDecl Multimap<?,?> actual)
public final ListMultimapSubject that(@NullableDecl ListMultimap<?,?> actual)
public final SetMultimapSubject that(@NullableDecl SetMultimap<?,?> actual)
public final MultisetSubject that(@NullableDecl Multiset<?> actual)
public final TableSubject that(@NullableDecl Table<?,?,?> actual)
public final AtomicLongMapSubject that(@NullableDecl AtomicLongMap<?> actual)
public final StandardSubjectBuilder withMessage(@NullableDecl String messageToPrepend)
public final StandardSubjectBuilder withMessage(@NullableDecl String format, Object... args)
Note: the arguments will be substituted into the format template using Strings.lenientFormat
. Note this only supports
the %s
specifier.
IllegalArgumentException
- if the number of placeholders in the format string does not
equal the number of given argumentspublic final <S extends Subject<S,A>,A> SimpleSubjectBuilder<S,A> about(Subject.Factory<S,A> factory)
Subject
class, returns a builder whose that(actual)
method creates instances of that class. Created subjects use the previously set failure
strategy and any previously set failure message.public final <CustomSubjectBuilderT extends CustomSubjectBuilder> CustomSubjectBuilderT about(CustomSubjectBuilder.Factory<CustomSubjectBuilderT> factory)
public final void fail()
Copyright © 2018. All rights reserved.