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 5656 <dependency >
5757 <groupId >io.dinject</groupId >
5858 <artifactId >dinject-generator</artifactId >
59- <version >1.18-SNAPSHOT </version >
59+ <version >1.18</version >
6060 <scope >test</scope >
6161 </dependency >
6262
Original file line number Diff line number Diff line change 99@ Factory
1010public class MyFactory {
1111
12+ String methods = "" ;
13+
1214 @ Bean
1315 CFact buildCFact () {
1416 return new CFact ();
@@ -30,4 +32,18 @@ Otherthing greenOther() {
3032 Otherthing yellowOther () {
3133 return () -> "yellow" ;
3234 }
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+ }
3349}
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