File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
src/test/java/org/example/coffee/factory Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 56
56
<dependency >
57
57
<groupId >io.dinject</groupId >
58
58
<artifactId >dinject-generator</artifactId >
59
- <version >1.18-SNAPSHOT </version >
59
+ <version >1.18</version >
60
60
<scope >test</scope >
61
61
</dependency >
62
62
Original file line number Diff line number Diff line change 9
9
@ Factory
10
10
public class MyFactory {
11
11
12
+ String methods = "" ;
13
+
12
14
@ Bean
13
15
CFact buildCFact () {
14
16
return new CFact ();
@@ -30,4 +32,18 @@ Otherthing greenOther() {
30
32
Otherthing yellowOther () {
31
33
return () -> "yellow" ;
32
34
}
35
+
36
+ @ Bean
37
+ void useCFact (CFact cfact ) {
38
+ methods +="|useCFact" ;
39
+ }
40
+
41
+ @ Bean
42
+ void anotherCFact (CFact cfact ) {
43
+ methods +="|anotherCFact" ;
44
+ }
45
+
46
+ String methodsCalled (){
47
+ return methods ;
48
+ }
33
49
}
Original file line number Diff line number Diff line change
1
+ package org .example .coffee .factory ;
2
+
3
+ import io .dinject .BeanContext ;
4
+ import io .dinject .BootContext ;
5
+ import org .junit .Test ;
6
+
7
+ import static org .assertj .core .api .Assertions .assertThat ;
8
+
9
+ public class MyFactoryTest {
10
+
11
+ @ Test
12
+ public void methodsCalled () {
13
+ try (BeanContext context = new BootContext ().load ()) {
14
+ final MyFactory myFactory = context .getBean (MyFactory .class );
15
+ assertThat (myFactory .methodsCalled ()).contains ("|useCFact" , "|anotherCFact" );
16
+ }
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments