Home | History | Annotate | Download | only in bugs
      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.bugs;
      7 
      8 import org.junit.Test;
      9 import org.mockito.ArgumentCaptor;
     10 import org.mockito.Captor;
     11 import org.mockito.Mock;
     12 import org.mockitoutil.TestBase;
     13 
     14 import static junit.framework.TestCase.assertEquals;
     15 import static org.mockito.Mockito.never;
     16 import static org.mockito.Mockito.verify;
     17 
     18 //see issue 188
     19 public class CaptorAnnotationAutoboxingTest extends TestBase {
     20 
     21     interface Fun {
     22         void doFun(double prmitive);
     23         void moreFun(int howMuch);
     24     }
     25 
     26     @Mock Fun fun;
     27     @Captor ArgumentCaptor<Double> captor;
     28 
     29     @Test
     30     public void shouldAutoboxSafely() {
     31         //given
     32         fun.doFun(1.0);
     33 
     34         //then
     35         verify(fun).doFun(captor.capture());
     36         assertEquals(1.0, captor.getValue());
     37     }
     38 
     39     @Captor ArgumentCaptor<Integer> intCaptor;
     40 
     41     @Test
     42     public void shouldAutoboxAllPrimitives() {
     43         verify(fun, never()).moreFun(intCaptor.capture());
     44     }
     45 }
     46