Home | History | Annotate | Download | only in basicapi
      1 /*
      2  * Copyright (c) 2007 Mockito contributors
      3  * This program is made available under the terms of the MIT License.
      4  */
      5 package org.mockitousage.basicapi;
      6 
      7 
      8 import org.junit.Test;
      9 
     10 import java.util.Set;
     11 
     12 import static org.junit.Assert.assertEquals;
     13 import static org.mockito.Mockito.mock;
     14 import static org.mockito.Mockito.when;
     15 
     16 public class MockAccessTest {
     17 
     18     @Test
     19     public void shouldAllowStubbedMockReferenceAccess() throws Exception {
     20         Set<?> expectedMock = mock(Set.class);
     21 
     22         Set<?> returnedMock = when(expectedMock.isEmpty()).thenReturn(false).getMock();
     23 
     24         assertEquals(expectedMock, returnedMock);
     25     }
     26 
     27     @Test
     28     public void stubbedMockShouldWorkAsUsual() throws Exception {
     29         Set<?> returnedMock = when(mock(Set.class).isEmpty()).thenReturn(false, true).getMock();
     30 
     31         assertEquals(false, returnedMock.isEmpty());
     32         assertEquals(true, returnedMock.isEmpty());
     33     }
     34 }
     35