1
1
package cucumber .runtime .java .needle .test ;
2
2
3
- import static org .hamcrest .CoreMatchers .is ;
4
- import static org .junit .Assert .assertNotNull ;
5
- import static org .junit .Assert .assertThat ;
6
- import static org .mockito .Mockito .when ;
7
-
8
- import javax .inject .Inject ;
9
-
10
- import org .hamcrest .core .Is ;
11
-
3
+ import cucumber .api .java .Before ;
12
4
import cucumber .api .java .en .Given ;
13
5
import cucumber .api .java .en .Then ;
14
6
import cucumber .api .java .en .When ;
7
+ import cucumber .api .needle .InjectionProviderInstancesSupplier ;
15
8
import cucumber .api .needle .NeedleInjectionProvider ;
9
+ import cucumber .runtime .java .needle .injection .DefaultInstanceInjectionProvider ;
16
10
import cucumber .runtime .java .needle .test .atm .AtmService ;
17
11
import cucumber .runtime .java .needle .test .atm .AtmServiceBean ;
18
12
import cucumber .runtime .java .needle .test .atm .BicGetter ;
19
13
import cucumber .runtime .java .needle .test .injectionprovider .ValueInjectionProvider ;
20
14
import de .akquinet .jbosscc .needle .annotation .ObjectUnderTest ;
21
15
import de .akquinet .jbosscc .needle .injection .InjectionProvider ;
16
+ import org .hamcrest .core .Is ;
17
+
18
+ import javax .inject .Inject ;
19
+
20
+ import java .util .Collections ;
21
+ import java .util .Set ;
22
+
23
+ import static org .hamcrest .CoreMatchers .is ;
24
+ import static org .junit .Assert .*;
25
+ import static org .mockito .Mockito .when ;
22
26
23
27
public class AtmWithdrawalSteps {
24
28
@@ -31,12 +35,23 @@ public class AtmWithdrawalSteps {
31
35
@ Inject
32
36
private BicGetter bicGetter ;
33
37
38
+ @ Inject
39
+ private MoreSteps moreSteps ;
40
+
34
41
/*
35
42
* Provider instance will be added dynamically.
36
43
*/
37
44
@ NeedleInjectionProvider
38
45
private final InjectionProvider <?> valueProvider = new ValueInjectionProvider (VALUE );
39
46
47
+ @ NeedleInjectionProvider
48
+ private final InjectionProviderInstancesSupplier thisInjectionProviderSupplier = new InjectionProviderInstancesSupplier () {
49
+ @ Override
50
+ public Set <InjectionProvider <?>> get () {
51
+ return Collections .<InjectionProvider <?>>singleton (new DefaultInstanceInjectionProvider <AtmWithdrawalSteps >(AtmWithdrawalSteps .this ));
52
+ }
53
+ };
54
+
40
55
/*
41
56
* This is what we test
42
57
*/
@@ -65,4 +80,12 @@ public void I_have_EUR_remaining(final int remaining) throws Throwable {
65
80
assertThat (atmService .getAmount (), Is .is (remaining ));
66
81
}
67
82
83
+ @ Before
84
+ public void checkInjectionWorked () {
85
+ assertTrue ("Got a mock injected instead of the real instance." , moreSteps .isThisReallyYouOrJustAMock ());
86
+ }
87
+
88
+ public boolean isThisReallyYouOrJustAMock () {
89
+ return true ;
90
+ }
68
91
}
0 commit comments