File tree Expand file tree Collapse file tree
core/src/test/java/dev/objz/commandbridge Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package dev .objz .commandbridge .net ;
2+
3+ import java .util .concurrent .CompletableFuture ;
4+
5+ import dev .objz .commandbridge .net .proto .Envelope ;
6+
7+ public class TestEndpoint implements Endpoint {
8+ private boolean open ;
9+
10+ public TestEndpoint () {
11+ this .open = true ;
12+ }
13+
14+ public TestEndpoint (boolean open ) {
15+ this .open = open ;
16+ }
17+
18+ @ Override
19+ public CompletableFuture <Void > send (Envelope env ) {
20+ return CompletableFuture .completedFuture (null );
21+ }
22+
23+ @ Override
24+ public boolean isOpen () {
25+ return open ;
26+ }
27+
28+ @ Override
29+ public String describe () {
30+ return "test-endpoint" ;
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ package dev .objz .commandbridge .scripting .validation ;
2+
3+ import java .lang .reflect .RecordComponent ;
4+ import java .util .Map ;
5+
6+ import dev .objz .commandbridge .scripting .bind .RecordBinder ;
7+
8+ public class ScriptFixtures {
9+
10+ public static RecordBinder .MutableRecordBuffer createBuffer (Class <?> recordClass ,
11+ Map <String , Object > fieldValues ) {
12+ RecordComponent [] components = recordClass .getRecordComponents ();
13+ Object [] values = new Object [components .length ];
14+
15+ for (int i = 0 ; i < components .length ; i ++) {
16+ String name = components [i ].getName ();
17+ if (fieldValues .containsKey (name )) {
18+ values [i ] = fieldValues .get (name );
19+ } else {
20+ values [i ] = null ;
21+ }
22+ }
23+
24+ return new RecordBinder .MutableRecordBuffer (recordClass , recordClass .getSimpleName (),
25+ components , values );
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments