Class LiteProtoSubject
- java.lang.Object
-
- com.google.common.truth.Subject
-
- com.google.common.truth.extensions.proto.LiteProtoSubject
-
- Direct Known Subclasses:
ProtoSubject
@CheckReturnValue public class LiteProtoSubject extends Subject
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 com.google.common.truth.Subject
Subject.Factory<SubjectT extends Subject,ActualT>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLiteProtoSubject(FailureMetadata failureMetadata, @Nullable MessageLite messageLite)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected StringactualCustomStringRepresentation()Supplies the direct string representation of the actual value to other methods which may prefix or otherwise position it in an error message.voidhasAllRequiredFields()Checks whether the subject has all required fields set.voidisEqualTo(@Nullable Object expected)Checks whether the MessageLite is equivalent to the argument, using the standard equals() implementation.voidisEqualTo(MessageLite.Builder builder)Deprecated.A Builder can never compare equal to a MessageLite instance.voidisEqualToDefaultInstance()Checks whether the subject is aMessageLitewith no fields set.voidisNotEqualTo(@Nullable Object expected)Fails if the subject is equal to the given object.voidisNotEqualTo(MessageLite.Builder builder)Deprecated.A Builder will never compare equal to a MessageLite instance.voidisNotEqualToDefaultInstance()Checks whether the subject is not equivalent to aMessageLitewith no fields set.IntegerSubjectserializedSize()Returns anIntegerSubjecton the serialized size of the MessageLite.-
Methods inherited from class com.google.common.truth.Subject
check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isIn, isInstanceOf, isNoneOf, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString
-
-
-
-
Constructor Detail
-
LiteProtoSubject
protected LiteProtoSubject(FailureMetadata failureMetadata, @Nullable MessageLite messageLite)
-
-
Method Detail
-
actualCustomStringRepresentation
protected String actualCustomStringRepresentation()
Description copied from class:SubjectSupplies the direct string representation of the actual value to other methods which may prefix or otherwise position it in an error message. This should only be overridden to provide an improved string representation of the value under test, as it would appear in any given error message, and should not be used for additional prefixing.Subjects should override this with care.
By default, this returns
String.ValueOf(getActualValue()).- Overrides:
actualCustomStringRepresentationin classSubject
-
isEqualTo
public void isEqualTo(@Nullable Object expected)
Checks whether the MessageLite is equivalent to the argument, using the standard equals() implementation.
-
isEqualTo
@Deprecated public void isEqualTo(MessageLite.Builder builder)
Deprecated.A Builder can never compare equal to a MessageLite instance. Usebuild(), orbuildPartial()on the argument to get a MessageLite for comparison instead.
-
isNotEqualTo
public void isNotEqualTo(@Nullable Object expected)
Description copied from class:SubjectFails if the subject is equal to the given object. The meaning of equality is the same as for theSubject.isEqualTo(java.lang.Object)method.- Overrides:
isNotEqualToin classSubject
-
isNotEqualTo
@Deprecated public void isNotEqualTo(MessageLite.Builder builder)
Deprecated.A Builder will never compare equal to a MessageLite instance. Usebuild(), orbuildPartial()on the argument to get a MessageLite for comparison instead.
-
isEqualToDefaultInstance
public void isEqualToDefaultInstance()
Checks whether the subject is aMessageLitewith no fields set.
-
isNotEqualToDefaultInstance
public void isNotEqualToDefaultInstance()
Checks whether the subject is not equivalent to aMessageLitewith no fields set.
-
hasAllRequiredFields
public void 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
public IntegerSubject 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.
-
-