Mockito ambiguous method call

Viewed 19725

I'm trying to stub out a method call, e.g.

when(amazonDynamoDBClient.batchWriteItem(anyObject())).thenReturn(batchWriteItemResultMock);

I get this error

Error:(198, 34) java: reference to batchWriteItem is ambiguous
  both method batchWriteItem(com.amazonaws.services.dynamodbv2.model.BatchWriteItemRequest) in com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient and method batchWriteItem(java.util.Map<java.lang.String,java.util.List<com.amazonaws.services.dynamodbv2.model.WriteRequest>>) in com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient match

I can't see how this is ambiguous - the method signatures are different, i.e.

public BatchWriteItemResult batchWriteItem(BatchWriteItemRequest request) {

and

public BatchWriteItemResult batchWriteItem(Map<String, List<WriteRequest>> requestItems) {

What am I doing wrong here?

2 Answers

For me, using isA() fixed the issue.

Docs : IsA

Related