public interface MultimapWithProtoValuesFluentAssertion<M extends com.google.protobuf.Message>
Multimap
s containing protocol
buffers as values. The same comparison rules are applied to all pairs of protocol buffers which
get compared.
The keys of these maps are treated as ordinary objects, and keys which happen to be
protocol buffers are not given special treatment. They are compared with Object#equals()
and Object.hashCode()
as documented by the Multimap
interface.
Methods may be chained in any order, but the chain should terminate with a method that doesn't
return a MultimapWithProtoValuesFluentAssertion
, such as #containsExactlyElementsIn
or containsEntry(java.lang.Object, M)
.
The state of a MultimapWithProtoValuesFluentAssertion
object after each method is
called is left undefined. Users should not retain references to MultimapWithProtoValuesFluentAssertion
instances.
Modifier and Type | Method and Description |
---|---|
void |
containsEntry(Object expectedKey,
M expectedValue)
Fails if the multimap does not contain an entry with the given key and a value that corresponds
to the given value.
|
Ordered |
containsExactly()
Fails if the multimap is not empty.
|
Ordered |
containsExactly(Object k0,
M v0,
Object... rest)
Fails if the multimap does not contain exactly the given set of key/value pairs.
|
Ordered |
containsExactlyEntriesIn(com.google.common.collect.Multimap<?,? extends M> expectedMultimap)
Fails if the map does not contain exactly the keys in the given multimap, mapping to values
that correspond to the values of the given multimap.
|
void |
doesNotContainEntry(Object excludedKey,
M excludedValue)
Fails if the multimap contains an entry with the given key and a value that corresponds to the
given value.
|
boolean |
equals(Object o)
Deprecated.
Do not call
equals() on a MultimapWithProtoValuesFluentAssertion . |
int |
hashCode()
Deprecated.
MultimapWithProtoValuesFluentAssertion does not support hashCode() . |
MultimapWithProtoValuesFluentAssertion<M> |
ignoringFieldAbsenceForValues()
Specifies that the 'has' bit of individual fields should be ignored when comparing for
equality.
|
MultimapWithProtoValuesFluentAssertion<M> |
ignoringFieldDescriptorsForValues(com.google.protobuf.Descriptors.FieldDescriptor firstFieldDescriptor,
com.google.protobuf.Descriptors.FieldDescriptor... rest)
Excludes all message fields matching the given
Descriptors.FieldDescriptor s from the comparison. |
MultimapWithProtoValuesFluentAssertion<M> |
ignoringFieldDescriptorsForValues(Iterable<com.google.protobuf.Descriptors.FieldDescriptor> fieldDescriptors)
Excludes all message fields matching the given
Descriptors.FieldDescriptor s from the comparison. |
MultimapWithProtoValuesFluentAssertion<M> |
ignoringFieldScopeForValues(FieldScope fieldScope)
Excludes all specific field paths under the argument
FieldScope from the comparison. |
MultimapWithProtoValuesFluentAssertion<M> |
ignoringFieldsForValues(int firstFieldNumber,
int... rest)
Excludes the top-level message fields with the given tag numbers from the comparison.
|
MultimapWithProtoValuesFluentAssertion<M> |
ignoringFieldsForValues(Iterable<Integer> fieldNumbers)
Excludes the top-level message fields with the given tag numbers from the comparison.
|
MultimapWithProtoValuesFluentAssertion<M> |
ignoringRepeatedFieldOrderForValues()
Specifies that the ordering of repeated fields, at all levels, should be ignored when comparing
for equality.
|
MultimapWithProtoValuesFluentAssertion<M> |
reportingMismatchesOnlyForValues()
If set, in the event of a comparison failure, the error message printed will list only those
specific fields that did not match between the actual and expected values.
|
MultimapWithProtoValuesFluentAssertion<M> |
withPartialScopeForValues(FieldScope fieldScope)
Limits the comparison of Protocol buffers to the defined
FieldScope . |
MultimapWithProtoValuesFluentAssertion<M> ignoringFieldAbsenceForValues()
For version 2 Protocol Buffers, this setting determines whether two protos with the same
value for a primitive field compare equal if one explicitly sets the value, and the other
merely implicitly uses the schema-defined default. This setting also determines whether unknown
fields should be considered in the comparison. By ignoringFieldAbsence()
, unknown
fields are ignored, and value-equal fields as specified above are considered equal.
For version 3 Protocol Buffers, this setting has no effect. Primitive fields set to their default value are indistinguishable from unset fields in proto 3. Proto 3 also eliminates unknown fields, so this setting has no effect there either.
MultimapWithProtoValuesFluentAssertion<M> ignoringRepeatedFieldOrderForValues()
This setting applies to all repeated fields recursively, but it does not ignore structure.
For example, with #ignoringRepeatedFieldOrder()
, a repeated int32
field bar
, set inside a repeated message field foo
, the following protos will all compare
equal:
message1: {
foo: {
bar: 1
bar: 2
}
foo: {
bar: 3
bar: 4
}
}
message2: {
foo: {
bar: 2
bar: 1
}
foo: {
bar: 4
bar: 3
}
}
message3: {
foo: {
bar: 4
bar: 3
}
foo: {
bar: 2
bar: 1
}
}
However, the following message will compare equal to none of these:
message4: {
foo: {
bar: 1
bar: 3
}
foo: {
bar: 2
bar: 4
}
}
This setting does not apply to map fields, for which field order is always ignored. The serialization order of map fields is undefined, and it may change from runtime to runtime.
MultimapWithProtoValuesFluentAssertion<M> withPartialScopeForValues(FieldScope fieldScope)
FieldScope
.
This method is additive and has well-defined ordering semantics. If the invoking MultimapWithProtoValuesFluentAssertion
is already scoped to a FieldScope
X
,
and this method is invoked with FieldScope
Y
, the resultant MultimapWithProtoValuesFluentAssertion
is constrained to the intersection of FieldScope
s X
and Y
.
By default, MultimapWithProtoValuesFluentAssertion
is constrained to FieldScopes.all()
, that is, no fields are excluded from comparison.
MultimapWithProtoValuesFluentAssertion<M> ignoringFieldsForValues(int firstFieldNumber, int... rest)
This method adds on any previous FieldScope
related settings, overriding previous
changes to ensure the specified fields are ignored recursively. All sub-fields of these field
numbers are ignored, and all sub-messages of type M
will also have these field numbers
ignored.
If an invalid field number is supplied, the terminal comparison operation will throw a runtime exception.
MultimapWithProtoValuesFluentAssertion<M> ignoringFieldsForValues(Iterable<Integer> fieldNumbers)
This method adds on any previous FieldScope
related settings, overriding previous
changes to ensure the specified fields are ignored recursively. All sub-fields of these field
numbers are ignored, and all sub-messages of type M
will also have these field numbers
ignored.
If an invalid field number is supplied, the terminal comparison operation will throw a runtime exception.
MultimapWithProtoValuesFluentAssertion<M> ignoringFieldDescriptorsForValues(com.google.protobuf.Descriptors.FieldDescriptor firstFieldDescriptor, com.google.protobuf.Descriptors.FieldDescriptor... rest)
Descriptors.FieldDescriptor
s from the comparison.
This method adds on any previous FieldScope
related settings, overriding previous
changes to ensure the specified fields are ignored recursively. All sub-fields of these field
descriptors are ignored, no matter where they occur in the tree.
If a field descriptor which does not, or cannot occur in the proto structure is supplied, it is silently ignored.
MultimapWithProtoValuesFluentAssertion<M> ignoringFieldDescriptorsForValues(Iterable<com.google.protobuf.Descriptors.FieldDescriptor> fieldDescriptors)
Descriptors.FieldDescriptor
s from the comparison.
This method adds on any previous FieldScope
related settings, overriding previous
changes to ensure the specified fields are ignored recursively. All sub-fields of these field
descriptors are ignored, no matter where they occur in the tree.
If a field descriptor which does not, or cannot occur in the proto structure is supplied, it is silently ignored.
MultimapWithProtoValuesFluentAssertion<M> ignoringFieldScopeForValues(FieldScope fieldScope)
FieldScope
from the comparison.
This method is additive and has well-defined ordering semantics. If the invoking MultimapWithProtoValuesFluentAssertion
is already scoped to a FieldScope
X
,
and this method is invoked with FieldScope
Y
, the resultant MultimapWithProtoValuesFluentAssertion
is constrained to the subtraction of X - Y
.
By default, MultimapWithProtoValuesFluentAssertion
is constrained to FieldScopes.all()
, that is, no fields are excluded from comparison.
MultimapWithProtoValuesFluentAssertion<M> reportingMismatchesOnlyForValues()
This a purely cosmetic setting, and it has no effect on the behavior of the test.
void containsEntry(@Nullable Object expectedKey, @Nullable M expectedValue)
void doesNotContainEntry(@Nullable Object excludedKey, @Nullable M excludedValue)
Ordered containsExactlyEntriesIn(com.google.common.collect.Multimap<?,? extends M> expectedMultimap)
A subsequent call to Ordered.inOrder()
may be made if the caller wishes to verify that
the two Multimaps iterate fully in the same order. That is, their key sets iterate in the same
order, and the corresponding value collections for each key iterate in the same order.
Ordered containsExactly()
Ordered containsExactly(@Nullable Object k0, @Nullable M v0, Object... rest)
Warning: the use of varargs means that we cannot guarantee an equal number of key/value pairs at compile time. Please make sure you provide varargs in key/value pairs!
@Deprecated boolean equals(Object o)
equals()
on a MultimapWithProtoValuesFluentAssertion
.equals
in class Object
Subject.equals(Object)
@Deprecated int hashCode()
MultimapWithProtoValuesFluentAssertion
does not support hashCode()
.hashCode
in class Object
Subject.hashCode()
Copyright © 2017. All rights reserved.