Reputation: 23800
I am trying to mock the following method:
@Override
public void handleStorage(TradeItem tradeItem,
ProductImagesMap productImagesMap,
List<Integer> indicesToProcess,
int countProductImages,
Queue<EcomImageMetadata> ecomImageMetadataQueue,
ImageServiceType imageServiceType,
ProductImageDTO productImageDTO) throws IllegalAccessException {
and this is how I am trying:
import static org.mockito.ArgumentMatchers.*;
final Class<Integer> integerClazz = Integer.class;
final Class<EcomImageMetadata> ecomImageMetadataClazz = EcomImageMetadata.class;
Mockito.when(productImageStorageService.handleStorage(eq(mockTradeItem), eq(productImagesMap), anyListOf(integerClazz), anyInt(), anyIterableOf(ecomImageMetadataClazz), anyObject(), anyObject()))
.thenReturn(null);
I do not understand why anyListOf(integerClazz)
works but anyIterableOf(ecomImageMetadataClazz)
is causing:
Error:(157, 152) java: incompatible types: no instance(s) of type variable(s) T exist so that java.lang.Iterable<T> conforms to java.util.Queue<org.gs1ca.dar.domain.EcomImageMetadata>
How do I match the Queue?
Upvotes: 0
Views: 221
Reputation: 15881
Use the generic version of the argument matcher ArgumentMatchers.any()
. In version java up to 7 you need to specify the type like this:
ArgumentMatchers.<Queue<EcomImageMetadata>>any()
If you are using java 8+ just use: ArgumentMatchers.any()
.
Upvotes: 2