1010import static org .mockito .Mockito .when ;
1111
1212import dev .dbos .transact .DBOS ;
13+ import dev .dbos .transact .internal .DBOSIntegration ;
1314import dev .dbos .transact .workflow .Step ;
1415import dev .dbos .transact .workflow .Workflow ;
1516
@@ -73,6 +74,9 @@ private static ConfigurableApplicationContext mockCtx(
7374 @ Test
7475 void registersBeansWithWorkflowMethods () throws Exception {
7576 var mockDbos = mock (DBOS .class );
77+ var mockIntegration = mock (DBOSIntegration .class );
78+ when (mockDbos .integration ()).thenReturn (mockIntegration );
79+
7680 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
7781 var mockCtx = mockCtx (mockBeanFactory , "workflowBean" );
7882 var bean = new BeanWithWorkflow ();
@@ -86,25 +90,31 @@ void registersBeansWithWorkflowMethods() throws Exception {
8690 var wfTag = method .getAnnotation (Workflow .class );
8791 assertNotNull (wfTag );
8892
89- verify (mockDbos ).registerWorkflow (eq (wfTag ), eq (bean ), eq (method ), eq (null ));
93+ verify (mockIntegration ).registerWorkflow (eq (wfTag ), eq (bean ), eq (method ), eq (null ));
9094 }
9195
9296 @ Test
9397 void skipsBeansWithoutWorkflowMethods () {
9498 var mockDbos = mock (DBOS .class );
99+ var mockIntegration = mock (DBOSIntegration .class );
100+ when (mockDbos .integration ()).thenReturn (mockIntegration );
101+
95102 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
96103 var mockCtx = mockCtx (mockBeanFactory , "plainBean" );
97104
98105 when (mockCtx .getBean ("plainBean" )).thenReturn (new BeanWithoutWorkflow ());
99106
100107 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
101108
102- verify (mockDbos , never ()).registerWorkflow (any (), any (), any (), any ());
109+ verify (mockIntegration , never ()).registerWorkflow (any (), any (), any (), any ());
103110 }
104111
105112 @ Test
106113 void skipsBeansThatThrowOnLookup () {
107114 var mockDbos = mock (DBOS .class );
115+ var mockIntegration = mock (DBOSIntegration .class );
116+ when (mockDbos .integration ()).thenReturn (mockIntegration );
117+
108118 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
109119 var mockCtx = mockCtx (mockBeanFactory , "badBean" );
110120
@@ -113,12 +123,15 @@ void skipsBeansThatThrowOnLookup() {
113123 // should complete without throwing
114124 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
115125
116- verify (mockDbos , never ()).registerWorkflow (any (), any (), any (), any ());
126+ verify (mockIntegration , never ()).registerWorkflow (any (), any (), any (), any ());
117127 }
118128
119129 @ Test
120130 void processesMultipleBeans () {
121131 var mockDbos = mock (DBOS .class );
132+ var mockIntegration = mock (DBOSIntegration .class );
133+ when (mockDbos .integration ()).thenReturn (mockIntegration );
134+
122135 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
123136 var mockCtx = mockCtx (mockBeanFactory , "wfBean" , "plainBean" );
124137 var wfBean = new BeanWithWorkflow ();
@@ -129,13 +142,16 @@ void processesMultipleBeans() {
129142
130143 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
131144
132- verify (mockDbos ).registerWorkflow (any (), eq (wfBean ), any (), eq (null ));
133- verify (mockDbos , never ()).registerWorkflow (any (), eq (plainBean ), any (), any ());
145+ verify (mockIntegration ).registerWorkflow (any (), eq (wfBean ), any (), eq (null ));
146+ verify (mockIntegration , never ()).registerWorkflow (any (), eq (plainBean ), any (), any ());
134147 }
135148
136149 @ Test
137150 void registersMultipleBeansOfSameClassUsingBeanNames () {
138151 var mockDbos = mock (DBOS .class );
152+ var mockIntegration = mock (DBOSIntegration .class );
153+ when (mockDbos .integration ()).thenReturn (mockIntegration );
154+
139155 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
140156 var mockCtx = mockCtx (mockBeanFactory , "primaryBean" , "secondaryBean" );
141157 var primaryBean = new BeanWithWorkflow ();
@@ -153,13 +169,16 @@ void registersMultipleBeansOfSameClassUsingBeanNames() {
153169
154170 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
155171
156- verify (mockDbos ).registerWorkflow (any (), eq (primaryBean ), any (), eq (null ));
157- verify (mockDbos ).registerWorkflow (any (), eq (secondaryBean ), any (), eq ("secondaryBean" ));
172+ verify (mockIntegration ).registerWorkflow (any (), eq (primaryBean ), any (), eq (null ));
173+ verify (mockIntegration ).registerWorkflow (any (), eq (secondaryBean ), any (), eq ("secondaryBean" ));
158174 }
159175
160176 @ Test
161177 void beanWithBothWorkflowAndStep_onlyRegistersWorkflow () throws Exception {
162178 var mockDbos = mock (DBOS .class );
179+ var mockIntegration = mock (DBOSIntegration .class );
180+ when (mockDbos .integration ()).thenReturn (mockIntegration );
181+
163182 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
164183 var mockCtx = mockCtx (mockBeanFactory , "mixedBean" );
165184 var bean = new BeanWithWorkflowAndStep ();
@@ -169,15 +188,18 @@ void beanWithBothWorkflowAndStep_onlyRegistersWorkflow() throws Exception {
169188 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
170189
171190 var method = BeanWithWorkflowAndStep .class .getMethod ("myWorkflow" );
172- verify (mockDbos ).registerWorkflow (any (), eq (bean ), eq (method ), eq (null ));
173- verify (mockDbos , never ())
191+ verify (mockIntegration ).registerWorkflow (any (), eq (bean ), eq (method ), eq (null ));
192+ verify (mockIntegration , never ())
174193 .registerWorkflow (
175194 any (), any (), eq (BeanWithWorkflowAndStep .class .getMethod ("myStep" )), any ());
176195 }
177196
178197 @ Test
179198 void beanLookupFailureMidScan_doesNotPreventOtherBeanRegistration () {
180199 var mockDbos = mock (DBOS .class );
200+ var mockIntegration = mock (DBOSIntegration .class );
201+ when (mockDbos .integration ()).thenReturn (mockIntegration );
202+
181203 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
182204 var mockCtx = mockCtx (mockBeanFactory , "badBean" , "goodBean" );
183205 var goodBean = new BeanWithWorkflow ();
@@ -187,12 +209,15 @@ void beanLookupFailureMidScan_doesNotPreventOtherBeanRegistration() {
187209
188210 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
189211
190- verify (mockDbos ).registerWorkflow (any (), eq (goodBean ), any (), eq (null ));
212+ verify (mockIntegration ).registerWorkflow (any (), eq (goodBean ), any (), eq (null ));
191213 }
192214
193215 @ Test
194216 void inheritedWorkflowMethods_areDetectedAndRegistered () throws Exception {
195217 var mockDbos = mock (DBOS .class );
218+ var mockIntegration = mock (DBOSIntegration .class );
219+ when (mockDbos .integration ()).thenReturn (mockIntegration );
220+
196221 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
197222 var mockCtx = mockCtx (mockBeanFactory , "derivedBean" );
198223 var bean = new DerivedWorkflowBean ();
@@ -202,12 +227,15 @@ void inheritedWorkflowMethods_areDetectedAndRegistered() throws Exception {
202227 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
203228
204229 var method = BaseWorkflowBean .class .getDeclaredMethod ("baseWorkflow" );
205- verify (mockDbos ).registerWorkflow (any (), eq (bean ), eq (method ), eq (null ));
230+ verify (mockIntegration ).registerWorkflow (any (), eq (bean ), eq (method ), eq (null ));
206231 }
207232
208233 @ Test
209234 void nonSingletonBeanWithWorkflow_throwsIllegalStateException () {
210235 var mockDbos = mock (DBOS .class );
236+ var mockIntegration = mock (DBOSIntegration .class );
237+ when (mockDbos .integration ()).thenReturn (mockIntegration );
238+
211239 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
212240 var mockCtx = mockCtx (mockBeanFactory , "prototypeBean" );
213241
@@ -222,6 +250,9 @@ void nonSingletonBeanWithWorkflow_throwsIllegalStateException() {
222250 @ Test
223251 void nonSingletonBeanWithStep_throwsIllegalStateException () {
224252 var mockDbos = mock (DBOS .class );
253+ var mockIntegration = mock (DBOSIntegration .class );
254+ when (mockDbos .integration ()).thenReturn (mockIntegration );
255+
225256 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
226257 var mockCtx = mockCtx (mockBeanFactory , "prototypeBean" );
227258
@@ -236,6 +267,9 @@ void nonSingletonBeanWithStep_throwsIllegalStateException() {
236267 @ Test
237268 void registersMultipleBeansOfSameClassWithBeanNamesWhenNoneIsPrimary () {
238269 var mockDbos = mock (DBOS .class );
270+ var mockIntegration = mock (DBOSIntegration .class );
271+ when (mockDbos .integration ()).thenReturn (mockIntegration );
272+
239273 var mockBeanFactory = mock (ConfigurableListableBeanFactory .class );
240274 var mockCtx = mockCtx (mockBeanFactory , "beanA" , "beanB" );
241275 var beanA = new BeanWithWorkflow ();
@@ -253,7 +287,7 @@ void registersMultipleBeansOfSameClassWithBeanNamesWhenNoneIsPrimary() {
253287
254288 new DBOSWorkflowRegistrar (mockDbos , mockCtx ).afterSingletonsInstantiated ();
255289
256- verify (mockDbos ).registerWorkflow (any (), eq (beanA ), any (), eq ("beanA" ));
257- verify (mockDbos ).registerWorkflow (any (), eq (beanB ), any (), eq ("beanB" ));
290+ verify (mockIntegration ).registerWorkflow (any (), eq (beanA ), any (), eq ("beanA" ));
291+ verify (mockIntegration ).registerWorkflow (any (), eq (beanB ), any (), eq ("beanB" ));
258292 }
259293}
0 commit comments