Skip to content

Commit f9cc023

Browse files
committed
Fixed unit tests
1 parent 1d64ca0 commit f9cc023

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

driver/src/test/java/org/neo4j/driver/internal/cursor/AsyncResultCursorOnlyFactoryTest.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
import org.neo4j.driver.internal.spi.Connection;
3232

3333
import static org.hamcrest.CoreMatchers.containsString;
34-
import static org.hamcrest.CoreMatchers.equalTo;
3534
import static org.hamcrest.CoreMatchers.instanceOf;
3635
import static org.junit.Assert.assertThat;
36+
import static org.junit.jupiter.api.Assertions.assertSame;
3737
import static org.junit.jupiter.api.Assertions.assertThrows;
38+
import static org.junit.jupiter.api.Assertions.assertTrue;
3839
import static org.mockito.ArgumentMatchers.any;
3940
import static org.mockito.Mockito.mock;
4041
import static org.mockito.Mockito.verify;
@@ -58,7 +59,7 @@ void shouldReturnAsyncResultWhenRunSucceeded()
5859
}
5960

6061
@Test
61-
void shouldFailAsyncResultWhenRunFailed()
62+
void shouldReturnAsyncResultWithRunErrorWhenRunFailed()
6263
{
6364
// Given
6465
Throwable error = new RuntimeException( "Hi there" );
@@ -68,8 +69,9 @@ void shouldFailAsyncResultWhenRunFailed()
6869
CompletionStage<AsyncResultCursor> cursorFuture = cursorFactory.asyncResult();
6970

7071
// Then
71-
CompletionException actual = assertThrows( CompletionException.class, () -> getNow( cursorFuture ) );
72-
assertThat( actual.getCause(), equalTo( error ) );
72+
AsyncResultCursor cursor = getNow( cursorFuture );
73+
assertTrue( cursor.runError().isPresent() );
74+
assertSame( error, cursor.runError().get() );
7375
}
7476

7577
@Test

driver/src/test/java/org/neo4j/driver/internal/cursor/ResultCursorFactoryImplTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.junit.jupiter.api.Test;
2222

2323
import java.util.concurrent.CompletableFuture;
24-
import java.util.concurrent.CompletionException;
2524
import java.util.concurrent.CompletionStage;
2625

2726
import org.neo4j.driver.internal.handlers.PullAllResponseHandler;
@@ -30,10 +29,10 @@
3029
import org.neo4j.driver.internal.messaging.Message;
3130
import org.neo4j.driver.internal.spi.Connection;
3231

33-
import static org.hamcrest.CoreMatchers.equalTo;
3432
import static org.hamcrest.CoreMatchers.instanceOf;
3533
import static org.junit.Assert.assertThat;
36-
import static org.junit.jupiter.api.Assertions.assertThrows;
34+
import static org.junit.jupiter.api.Assertions.assertSame;
35+
import static org.junit.jupiter.api.Assertions.assertTrue;
3736
import static org.mockito.ArgumentMatchers.any;
3837
import static org.mockito.Mockito.mock;
3938
import static org.mockito.Mockito.verify;
@@ -58,7 +57,7 @@ void shouldReturnAsyncResultWhenRunSucceeded()
5857
}
5958

6059
@Test
61-
void shouldFailAsyncResultWhenRunFailed()
60+
void shouldReturnAsyncResultWithRunErrorWhenRunFailed()
6261
{
6362
// Given
6463
Throwable error = new RuntimeException( "Hi there" );
@@ -68,8 +67,9 @@ void shouldFailAsyncResultWhenRunFailed()
6867
CompletionStage<AsyncResultCursor> cursorFuture = cursorFactory.asyncResult();
6968

7069
// Then
71-
CompletionException actual = assertThrows( CompletionException.class, () -> getNow( cursorFuture ) );
72-
assertThat( actual.getCause(), equalTo( error ) );
70+
AsyncResultCursor cursor = getNow( cursorFuture );
71+
assertTrue( cursor.runError().isPresent() );
72+
assertSame( error, cursor.runError().get() );
7373
}
7474

7575
@Test

driver/src/test/java/org/neo4j/driver/internal/handlers/RunResponseHandlerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void shouldMarkTxAndKeepConnectionAndFailOnFailure()
154154
}
155155

156156
@Test
157-
void shouldReleaseConnectionAndFailOnFailure()
157+
void shouldNotReleaseConnectionAndFailOnFailure()
158158
{
159159
CompletableFuture<Void> runFuture = new CompletableFuture<>();
160160
Connection connection = mock( Connection.class );
@@ -167,7 +167,7 @@ void shouldReleaseConnectionAndFailOnFailure()
167167
assertTrue( runFuture.isCompletedExceptionally() );
168168
Throwable actualException = assertThrows( Throwable.class, () -> await( runFuture ) );
169169
assertSame( throwable, actualException );
170-
verify( connection ).release();
170+
verify( connection, never() ).release();
171171
verify( connection, never() ).terminateAndRelease( any( String.class ) );
172172
}
173173

0 commit comments

Comments
 (0)