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.annotation;
7 
8 import org.junit.Test;
9 import org.junit.runner.RunWith;
10 import org.mockito.InjectMocks;
11 import org.mockito.Mock;
12 import org.mockito.internal.util.MockUtil;
13 import org.mockito.junit.MockitoJUnitRunner;
14 import org.mockitousage.examples.use.ArticleCalculator;
15 
16 import static org.assertj.core.api.Assertions.assertThat;
17 
18 @RunWith(MockitoJUnitRunner.class)
19 public class MockInjectionUsingConstructorIssue421Test {
20 
21     @Mock private ArticleCalculator calculator;
22 
23     @InjectMocks private Issue421 issue421;
24 
25     @Test
mockJustWorks()26     public void mockJustWorks() {
27         issue421.checkIfMockIsInjected();
28     }
29 
30     static class Issue421 {
31 
32         private ArticleCalculator calculator;
33 
Issue421(int a)34         public Issue421(int a) {
35         }
36 
Issue421(ArticleCalculator calculator)37         public Issue421(ArticleCalculator calculator) {
38             this.calculator = calculator;
39         }
40 
checkIfMockIsInjected()41         public void checkIfMockIsInjected(){
42             assertThat(MockUtil.isMock(calculator)).isTrue();
43         }
44     }
45 
46 }
47