• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.mockito.internal.progress;
7 
8 import org.junit.Before;
9 import org.junit.Test;
10 import org.mockito.exceptions.base.MockitoException;
11 import org.mockito.internal.verification.VerificationModeFactory;
12 import org.mockito.verification.VerificationMode;
13 import org.mockitoutil.TestBase;
14 
15 import static junit.framework.TestCase.*;
16 import static org.mockito.Matchers.eq;
17 import static org.mockito.Mockito.mock;
18 import static org.mockito.Mockito.verify;
19 
20 public class MockingProgressImplTest extends TestBase {
21 
22     private MockingProgress mockingProgress;
23 
24     @Before
setup()25     public void setup() {
26         mockingProgress = new MockingProgressImpl();
27     }
28 
29     @Test
shouldStartVerificationAndPullVerificationMode()30     public void shouldStartVerificationAndPullVerificationMode() throws Exception {
31         assertNull(mockingProgress.pullVerificationMode());
32 
33         VerificationMode mode = VerificationModeFactory.times(19);
34 
35         mockingProgress.verificationStarted(mode);
36 
37         assertSame(mode, mockingProgress.pullVerificationMode());
38 
39         assertNull(mockingProgress.pullVerificationMode());
40     }
41 
42     @Test
shouldCheckIfVerificationWasFinished()43     public void shouldCheckIfVerificationWasFinished() throws Exception {
44         mockingProgress.verificationStarted(VerificationModeFactory.atLeastOnce());
45         try {
46             mockingProgress.verificationStarted(VerificationModeFactory.atLeastOnce());
47             fail();
48         } catch (MockitoException e) {}
49     }
50 
51     @Test
shouldNotifyListenerSafely()52     public void shouldNotifyListenerSafely() throws Exception {
53         //when
54         mockingProgress.addListener(null);
55 
56         //then no exception is thrown:
57         mockingProgress.mockingStarted(null, null);
58     }
59 }
60