### Question:
AuthenticationService { public static Optional<AuthenticationService> create( final Vertx vertx, final JsonRpcConfiguration config) { return create( vertx, config.isAuthenticationEnabled(), config.getAuthenticationCredentialsFile(), config.getAuthenticationPublicKeyFile()); } private  AuthenticationService(
      final JWTAuth jwtAuthProvider,
      final JWTAuthOptions jwtAuthOptions,
      final Optional<AuthProvider> credentialAuthProvider); static Optional<AuthenticationService> create(
      final Vertx vertx, final JsonRpcConfiguration config); static Optional<AuthenticationService> create(
      final Vertx vertx, final WebSocketConfiguration config); static void handleDisabledLogin(final RoutingContext routingContext); void handleLogin(final RoutingContext routingContext); JWTAuth getJwtAuthProvider(); @VisibleForTesting final JWTAuthOptions jwtAuthOptions; }### Answer:
@Test public void authenticationServiceNotCreatedWhenRpcAuthenticationDisabledAndHasCredentialsFile() { final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); jsonRpcConfiguration.setAuthenticationEnabled(false); jsonRpcConfiguration.setAuthenticationCredentialsFile("some/file/path"); final Optional<AuthenticationService> authenticationService = AuthenticationService.create(vertx, jsonRpcConfiguration); assertThat(authenticationService).isEmpty(); }
@Test public void authenticationServiceNotCreatedWhenRpcAuthenticationDisabledAndHasPublicKeyFile() throws IOException { final File publicKeyFile = File.createTempFile("publicKey", "jwt"); final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); jsonRpcConfiguration.setAuthenticationEnabled(false); jsonRpcConfiguration.setAuthenticationPublicKeyFile(publicKeyFile); final Optional<AuthenticationService> authenticationService = AuthenticationService.create(vertx, jsonRpcConfiguration); assertThat(authenticationService).isEmpty(); }
@Test public void authenticationServiceNotCreatedWhenRpcAuthenticationDisabledAndNoCredentialsFileOrPublicKeyFile() throws IOException { final File publicKeyFile = File.createTempFile("publicKey", "jwt"); final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); jsonRpcConfiguration.setAuthenticationEnabled(false); jsonRpcConfiguration.setAuthenticationPublicKeyFile(publicKeyFile); jsonRpcConfiguration.setAuthenticationCredentialsFile("some/file/path"); final Optional<AuthenticationService> authenticationService = AuthenticationService.create(vertx, jsonRpcConfiguration); assertThat(authenticationService).isEmpty(); }
@Test public void authenticationServiceNotCreatedWhenWsAuthenticationDisabledAndHasCredentialsFile() { final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); webSocketConfiguration.setAuthenticationEnabled(false); webSocketConfiguration.setAuthenticationCredentialsFile("some/file/path"); final Optional<AuthenticationService> authenticationService = AuthenticationService.create(vertx, webSocketConfiguration); assertThat(authenticationService).isEmpty(); }
@Test public void authenticationServiceNotCreatedWhenWsAuthenticationDisabledAndHasPublicKeyFile() throws IOException { final File publicKeyFile = File.createTempFile("publicKey", "jwt"); final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); webSocketConfiguration.setAuthenticationEnabled(false); webSocketConfiguration.setAuthenticationPublicKeyFile(publicKeyFile); final Optional<AuthenticationService> authenticationService = AuthenticationService.create(vertx, webSocketConfiguration); assertThat(authenticationService).isEmpty(); }
@Test public void authenticationServiceNotCreatedWhenWsAuthenticationDisabledAndNoCredentialsFileOrPublicKeyFile() throws IOException { final File publicKeyFile = File.createTempFile("publicKey", "jwt"); final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); webSocketConfiguration.setAuthenticationEnabled(false); webSocketConfiguration.setAuthenticationPublicKeyFile(publicKeyFile); webSocketConfiguration.setAuthenticationCredentialsFile("some/file/path"); final Optional<AuthenticationService> authenticationService = AuthenticationService.create(vertx, webSocketConfiguration); assertThat(authenticationService).isEmpty(); }