Description
Some of the api-commands under com.basho.riak.client.api.commands
do not override the equals()
-method (nor hashCode()
).
Context
For unit-testing my client-code I would like to mock the RiakClient
, especially its execute()
-method:
// example assumes mockito
FetchBucketProperties fetchBucketProperties = new FetchBucketProperties.Builder(new Namespace(TYPES_BUCKET_NAME)).build();
FetchBucketPropsOperation.Response fetchedBucketProperties = mock(FetchBucketPropsOperation.Response.class);
when(riakClient.execute(fetchBucketProperties)).thenReturn(fetchedBucketProperties);
But, since I cannot record the mock with the same command-instance as created by the caller of riakClient.execute()
, my recorded invocation never matches.
Affected commands that I detected so far: FetchBucketProperties
, StoreBucketProperties
, StoreIndex
.
Expected Behavior
When I mock as in the example above, invocations of riakClient.execute()
with a FetchBucketProperties
for the same Namespace
should match my recording.
Actual Behavior
Since FetchBucketProperties
doesn't override equals()
, my recording does not take effect.
Possible Fix
Well, implementing equals()
and hashCode()
for the affected classes would help. I'm trying to provide a Pull request within the next week.