Class LiteProtoSubject
java.lang.Object
com.google.common.truth.Subject
com.google.common.truth.extensions.proto.LiteProtoSubject
- Direct Known Subclasses:
ProtoSubject
Truth subjects for the Lite version of Protocol Buffers.
LiteProtoSubject supports versions 2 and 3 of Protocol Buffers. Due to the lack of runtime descriptors, its functionality is limited compared to ProtoSubject, in particular in performing detailed comparisons between messages.
-
Nested Class Summary
Nested classes/interfaces inherited from class Subject
Subject.Factory<SubjectT,ActualT> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLiteProtoSubject(FailureMetadata failureMetadata, @Nullable MessageLite messageLite) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringReturns a string representation of the actual value for inclusion in failure messages.voidChecks whether the subject has all required fields set.voidisEqualTo(@Nullable MessageLite.Builder builder) DO NOT CALL THIS METHOD!voidChecks whether the MessageLite is equivalent to the argument, using the standard equals() implementation.voidChecks whether the subject is aMessageLitewith no fields set.voidisNotEqualTo(@Nullable MessageLite.Builder builder) DO NOT CALL THIS METHOD!voidisNotEqualTo(@Nullable Object expected) Checks that the value under test is not equal to the given object.voidChecks whether the subject is not equivalent to aMessageLitewith no fields set.Returns anIntegerSubjecton the serialized size of the MessageLite.Methods inherited from class Subject
check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isIn, isInstanceOf, isNoneOf, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toStringModifier and TypeMethodDescriptionprotected final StandardSubjectBuilderReturns a builder for creating a derived subject.final booleanDeprecated.protected final voidfailWithActual(Fact first, Fact... rest) Fails, reporting a message with the given facts, followed by an automatically added fact of the form: but was: actual value.protected final voidfailWithActual(String key, @Nullable Object value) Fails, reporting a message with two "facts": key: value but was: actual value.protected final voidfailWithoutActual(Fact first, Fact... rest) Fails, reporting a message with the given facts, without automatically adding the actual value.final inthashCode()Deprecated.Object.hashCode()is not supported on Truth subjects.protected final StandardSubjectBuilderBegins a new call chain that ignores any failures.voidChecks that the value under test is equal to any of the given elements.voidChecks that the value under test is equal to any element in the given iterable.voidisInstanceOf(@Nullable Class<?> clazz) Checks that the value under test is an instance of the given class.voidChecks that the value under test is not equal to any of the given elements.voidChecks that the value under test is not equal to any element in the given iterable.voidisNotInstanceOf(@Nullable Class<?> clazz) Checks that the value under test is not an instance of the given class.voidChecks that the value under test is not null.final voidisNotSameInstanceAs(@Nullable Object other) Checks that the value under test is not the same instance as the given object.voidisNull()Checks that the value under test is null.final voidisSameInstanceAs(@Nullable Object expected) Checks that the value under test is the same instance as the given object.toString()Deprecated.Object.toString()is not supported on Truth subjects.
-
Constructor Details
-
LiteProtoSubject
-
-
Method Details
-
actualCustomStringRepresentation
Description copied from class:SubjectReturns a string representation of the actual value for inclusion in failure messages.Subjects should override this with care.
By default, this method returns
String.valueOf(getActualValue())for most types. It does have some special logic for a few cases, like arrays.- Overrides:
actualCustomStringRepresentationin classSubject
-
isEqualTo
-
isEqualTo
DO NOT CALL THIS METHOD!. AMessageLite.Builderwill never compare equal to a MessageLite instance. Usebuild(), orbuildPartial()on the argument to get a MessageLite for comparison instead. Or, if you are passingnull, useSubject.isNull(). -
isNotEqualTo
Description copied from class:SubjectChecks that the value under test is not equal to the given object. The meaning of equality is the same as for theSubject.isEqualTo(Object)method.- Overrides:
isNotEqualToin classSubject
-
isNotEqualTo
DO NOT CALL THIS METHOD!. AMessageLite.Builderwill never compare equal to aMessageLiteinstance. Usebuild(), orbuildPartial()on the argument to get aMessageLitefor comparison instead. Or, if you are passingnull, useSubject.isNotNull(). -
isEqualToDefaultInstance
Checks whether the subject is aMessageLitewith no fields set. -
isNotEqualToDefaultInstance
Checks whether the subject is not equivalent to aMessageLitewith no fields set. -
hasAllRequiredFields
Checks whether the subject has all required fields set. Cannot fail for a proto built withbuild(), which itself fails if required fields aren't set. -
serializedSize
Returns anIntegerSubjecton the serialized size of the MessageLite.Assertions can then be changed on the serialized size, to support checks such as
assertThat(myProto).serializedSize().isAtLeast(16), etc.
-
Object.equals(Object)is not supported on Truth subjects.