Skip to content

Commit 7bf80a7

Browse files
authored
Add Temporary:ResultKeys support in Testkit backend (#1113) (#1118)
1 parent 6f12e4c commit 7bf80a7

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/GetFeatures.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public class GetFeatures implements TestkitRequest
5858
"Temporary:ConnectionAcquisitionTimeout",
5959
"Temporary:GetConnectionPoolMetrics",
6060
"Temporary:CypherPathAndRelationship",
61-
"Temporary:FullSummary"
61+
"Temporary:FullSummary",
62+
"Temporary:ResultKeys"
6263
) );
6364

6465
private static final Set<String> SYNC_FEATURES = new HashSet<>( Arrays.asList(

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/SessionRun.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import reactor.core.publisher.Mono;
3333

3434
import java.time.Duration;
35+
import java.util.List;
3536
import java.util.Map;
3637
import java.util.Optional;
3738
import java.util.concurrent.CompletionStage;
@@ -63,7 +64,7 @@ public TestkitResponse process( TestkitState testkitState )
6364
org.neo4j.driver.Result result = session.run( query, transactionConfig.build() );
6465
String id = testkitState.addResultHolder( new ResultHolder( sessionHolder, result ) );
6566

66-
return createResponse( id );
67+
return createResponse( id, result.keys() );
6768
}
6869

6970
@Override
@@ -86,7 +87,7 @@ public CompletionStage<TestkitResponse> processAsync( TestkitState testkitState
8687
{
8788
String id = testkitState.addAsyncResultHolder(
8889
new ResultCursorHolder( sessionHolder, resultCursor ) );
89-
return createResponse( id );
90+
return createResponse( id, resultCursor.keys() );
9091
} );
9192
} );
9293
}
@@ -111,13 +112,13 @@ public Mono<TestkitResponse> processRx( TestkitState testkitState )
111112
// The keys() method causes RUN message exchange.
112113
// However, it does not currently report errors.
113114
return Mono.fromDirect( result.keys() )
114-
.map( ignored -> createResponse( id ) );
115+
.map( keys -> createResponse( id, keys ) );
115116
} );
116117
}
117118

118-
private Result createResponse( String resultId )
119+
private Result createResponse( String resultId, List<String> keys )
119120
{
120-
return Result.builder().data( Result.ResultBody.builder().id( resultId ).build() ).build();
121+
return Result.builder().data( Result.ResultBody.builder().id( resultId ).keys( keys ).build() ).build();
121122
}
122123

123124
@Setter

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/TransactionRun.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import reactor.core.publisher.Mono;
3333

3434
import java.util.Collections;
35+
import java.util.List;
3536
import java.util.Map;
3637
import java.util.concurrent.CompletionStage;
3738

@@ -50,7 +51,7 @@ public TestkitResponse process( TestkitState testkitState )
5051
org.neo4j.driver.Result result = transactionHolder.getTransaction()
5152
.run( data.getCypher(), data.getParams() != null ? data.getParams() : Collections.emptyMap() );
5253
String resultId = testkitState.addResultHolder( new ResultHolder( transactionHolder, result ) );
53-
return createResponse( resultId );
54+
return createResponse( resultId, result.keys() );
5455
}
5556

5657
@Override
@@ -65,7 +66,7 @@ public CompletionStage<TestkitResponse> processAsync( TestkitState testkitState
6566
String resultId = testkitState.addAsyncResultHolder(
6667
new ResultCursorHolder( transactionHolder,
6768
resultCursor ) );
68-
return createResponse( resultId );
69+
return createResponse( resultId, resultCursor.keys() );
6970
} ) );
7071
}
7172

@@ -81,13 +82,13 @@ public Mono<TestkitResponse> processRx( TestkitState testkitState )
8182
String resultId = testkitState.addRxResultHolder( new RxResultHolder( transactionHolder, result ) );
8283
// The keys() method causes RUN message exchange.
8384
// However, it does not currently report errors.
84-
return Mono.fromDirect( result.keys() ).then( Mono.just( createResponse( resultId ) ) );
85+
return Mono.fromDirect( result.keys() ).map( keys -> createResponse( resultId, keys ) );
8586
} );
8687
}
8788

88-
protected Result createResponse( String resultId )
89+
protected Result createResponse( String resultId, List<String> keys )
8990
{
90-
return Result.builder().data( Result.ResultBody.builder().id( resultId ).build() ).build();
91+
return Result.builder().data( Result.ResultBody.builder().id( resultId ).keys( keys ).build() ).build();
9192
}
9293

9394
@Setter

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/responses/Result.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import lombok.Builder;
2222
import lombok.Getter;
2323

24+
import java.util.List;
25+
2426
@Getter
2527
@Builder
2628
public class Result implements TestkitResponse
@@ -38,5 +40,7 @@ public String testkitName()
3840
public static class ResultBody
3941
{
4042
private String id;
43+
44+
private List<String> keys;
4145
}
4246
}

0 commit comments

Comments
 (0)