|
69 | 69 | import static org.junit.jupiter.api.Assertions.assertTrue; |
70 | 70 | import static org.mockito.ArgumentMatchers.any; |
71 | 71 | import static org.mockito.ArgumentMatchers.eq; |
| 72 | +import static org.mockito.Mockito.doAnswer; |
72 | 73 | import static org.mockito.Mockito.mock; |
73 | 74 | import static org.mockito.Mockito.verify; |
| 75 | +import static org.mockito.Mockito.when; |
74 | 76 | import static org.neo4j.driver.internal.util.ServerVersion.v3_5_0; |
75 | 77 | import static org.neo4j.driver.v1.Values.value; |
| 78 | +import static org.neo4j.driver.v1.util.TestUtil.DEFAULT_TEST_PROTOCOL; |
76 | 79 | import static org.neo4j.driver.v1.util.TestUtil.await; |
77 | 80 | import static org.neo4j.driver.v1.util.TestUtil.connectionMock; |
78 | 81 |
|
@@ -194,12 +197,21 @@ void shouldBeginTransactionWithBookmarksAndConfig() |
194 | 197 | @Test |
195 | 198 | void shouldCommitTransaction() |
196 | 199 | { |
197 | | - Connection connection = connectionMock(); |
| 200 | + String bookmarkString = "neo4j:bookmark:v1:tx4242"; |
198 | 201 |
|
199 | | - CompletionStage<Void> stage = protocol.commitTransaction( connection, mock( ExplicitTransaction.class ) ); |
| 202 | + Connection connection = mock( Connection.class ); |
| 203 | + when( connection.protocol() ).thenReturn( DEFAULT_TEST_PROTOCOL ); |
| 204 | + doAnswer( invocation -> |
| 205 | + { |
| 206 | + ResponseHandler commitHandler = invocation.getArgument( 1 ); |
| 207 | + commitHandler.onSuccess( singletonMap( "bookmark", value( bookmarkString ) ) ); |
| 208 | + return null; |
| 209 | + } ).when( connection ).writeAndFlush( eq( CommitMessage.COMMIT ), any() ); |
| 210 | + |
| 211 | + CompletionStage<Bookmarks> stage = protocol.commitTransaction( connection ); |
200 | 212 |
|
201 | 213 | verify( connection ).writeAndFlush( eq( CommitMessage.COMMIT ), any( CommitTxResponseHandler.class ) ); |
202 | | - assertNull( await( stage ) ); |
| 214 | + assertEquals( Bookmarks.from( bookmarkString ), await( stage ) ); |
203 | 215 | } |
204 | 216 |
|
205 | 217 | @Test |
|
0 commit comments