File tree 1 file changed +8
-8
lines changed
core/src/test/java/com/avast/grpc/jwt/server
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 8
8
import io .grpc .ServerCall ;
9
9
import io .grpc .ServerCallHandler ;
10
10
import java .util .concurrent .CompletableFuture ;
11
- import java .util .concurrent .CompletionException ;
12
11
import java .util .concurrent .atomic .AtomicReference ;
13
12
import org .junit .Test ;
14
13
15
14
public class JwtServerInterceptorTest {
16
15
17
16
JwtTokenParser <String > jwtTokenParser =
18
- jwtToken ->
19
- CompletableFuture .supplyAsync (
20
- () -> {
21
- if (jwtToken .equals ("Invalid Token" ))
22
- throw new CompletionException (new RuntimeException ("invalid token" ));
23
- return jwtToken ;
24
- });
17
+ jwtToken -> {
18
+ if (jwtToken .equals ("Invalid Token" )) {
19
+ CompletableFuture <String > res = new CompletableFuture <>();
20
+ res .completeExceptionally (new RuntimeException ("invalid token" ));
21
+ return res ;
22
+ }
23
+ return CompletableFuture .completedFuture (jwtToken );
24
+ };
25
25
JwtServerInterceptor <String > target = new JwtServerInterceptor <>(jwtTokenParser );
26
26
ServerCall <Object , Object > serverCall = (ServerCall <Object , Object >) mock (ServerCall .class );
27
27
ServerCallHandler <Object , Object > next =
You can’t perform that action at this time.
0 commit comments