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.

  • Constructor Details

  • Method Details

    • actualCustomStringRepresentation

      protected String actualCustomStringRepresentation()
      Description copied from class: Subject
      Returns 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:
      actualCustomStringRepresentation in class Subject
    • isEqualTo

      public void isEqualTo(@Nullable Object expected)
      Checks whether the MessageLite is equivalent to the argument, using the standard equals() implementation.
      Overrides:
      isEqualTo in class Subject
    • isEqualTo

      @Deprecated public void isEqualTo(@Nullable MessageLite.Builder builder)
      Deprecated.
      A Builder can never compare equal to a MessageLite instance. Use build(), or buildPartial() on the argument to get a MessageLite for comparison instead. Or, if you are passing null, use Subject.isNull().
    • isNotEqualTo

      public void isNotEqualTo(@Nullable Object expected)
      Description copied from class: Subject
      Checks that the value under test is not equal to the given object. The meaning of equality is the same as for the Subject.isEqualTo(java.lang.Object) method.
      Overrides:
      isNotEqualTo in class Subject
    • isNotEqualTo

      @Deprecated public void isNotEqualTo(@Nullable MessageLite.Builder builder)
      Deprecated.
      A Builder will never compare equal to a MessageLite instance. Use build(), or buildPartial() on the argument to get a MessageLite for comparison instead. Or, if you are passing null, use Subject.isNotNull().
    • isEqualToDefaultInstance

      public void isEqualToDefaultInstance()
      Checks whether the subject is a MessageLite with no fields set.
    • isNotEqualToDefaultInstance

      public void isNotEqualToDefaultInstance()
      Checks whether the subject is not equivalent to a MessageLite with no fields set.
    • hasAllRequiredFields

      public void hasAllRequiredFields()
      Checks whether the subject has all required fields set. Cannot fail for a proto built with build(), which itself fails if required fields aren't set.
    • serializedSize

      public IntegerSubject serializedSize()
      Returns an IntegerSubject on 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.