1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 
6 package org.mockitousage.matchers;
7 
8 import org.junit.Test;
9 import org.mockito.ArgumentMatchers;
10 import org.mockito.Mock;
11 import org.mockitoutil.TestBase;
12 
13 import java.util.Date;
14 import java.util.List;
15 
16 import static org.mockito.Matchers.anyObject;
17 import static org.mockito.Mockito.when;
18 
19 public class GenericMatchersTest extends TestBase {
20 
21     private interface Foo {
sort(List<String> otherList)22         List<String> sort(List<String> otherList);
convertDate(Date date)23         String convertDate(Date date);
24     }
25 
26     @Mock Foo sorter;
27 
28     @SuppressWarnings("unchecked")
29     @Test
shouldCompile()30     public void shouldCompile() {
31         when(sorter.convertDate(new Date())).thenReturn("one");
32         when(sorter.convertDate((Date) anyObject())).thenReturn("two");
33 
34         //following requires warning suppression but allows setting anyList()
35         when(sorter.sort(ArgumentMatchers.<String>anyList())).thenReturn(null);
36     }
37 }
38