@Test public void register_fail() { HttpServerRequest serverRequest = Mockito.mock(HttpServerRequest.class); when(routingContext.request()).thenReturn(serverRequest); when(dcrService.create(any(),any())).thenReturn(Single.error(new Exception())); endpoint.handle(routingContext); verify(routingContext, times(1)).fail(any()); }
@Override public void handle(RoutingContext context) { LOGGER.debug("Dynamic client registration CREATE endpoint"); this.extractRequest(context) .flatMap(request -> dcrService.create(request, UriBuilderRequest.resolveProxyRequest(context))) .map(clientSyncService::addDynamicClientRegistred) .subscribe( client -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.CREATED_201) .end(Json.encodePrettily(DynamicClientRegistrationResponse.fromClient(client))) , error -> context.fail(error) ); }
DynamicClientRegistrationEndpoint implements Handler<RoutingContext> { @Override public void handle(RoutingContext context) { LOGGER.debug("Dynamic client registration CREATE endpoint"); this.extractRequest(context) .flatMap(request -> dcrService.create(request, UriBuilderRequest.resolveProxyRequest(context))) .map(clientSyncService::addDynamicClientRegistred) .subscribe( client -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.CREATED_201) .end(Json.encodePrettily(DynamicClientRegistrationResponse.fromClient(client))) , error -> context.fail(error) ); } }
DynamicClientRegistrationEndpoint implements Handler<RoutingContext> { @Override public void handle(RoutingContext context) { LOGGER.debug("Dynamic client registration CREATE endpoint"); this.extractRequest(context) .flatMap(request -> dcrService.create(request, UriBuilderRequest.resolveProxyRequest(context))) .map(clientSyncService::addDynamicClientRegistred) .subscribe( client -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.CREATED_201) .end(Json.encodePrettily(DynamicClientRegistrationResponse.fromClient(client))) , error -> context.fail(error) ); } DynamicClientRegistrationEndpoint(DynamicClientRegistrationService dcrService, ClientSyncService clientSyncService); }
DynamicClientRegistrationEndpoint implements Handler<RoutingContext> { @Override public void handle(RoutingContext context) { LOGGER.debug("Dynamic client registration CREATE endpoint"); this.extractRequest(context) .flatMap(request -> dcrService.create(request, UriBuilderRequest.resolveProxyRequest(context))) .map(clientSyncService::addDynamicClientRegistred) .subscribe( client -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.CREATED_201) .end(Json.encodePrettily(DynamicClientRegistrationResponse.fromClient(client))) , error -> context.fail(error) ); } DynamicClientRegistrationEndpoint(DynamicClientRegistrationService dcrService, ClientSyncService clientSyncService); @Override void handle(RoutingContext context); }
DynamicClientRegistrationEndpoint implements Handler<RoutingContext> { @Override public void handle(RoutingContext context) { LOGGER.debug("Dynamic client registration CREATE endpoint"); this.extractRequest(context) .flatMap(request -> dcrService.create(request, UriBuilderRequest.resolveProxyRequest(context))) .map(clientSyncService::addDynamicClientRegistred) .subscribe( client -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.CREATED_201) .end(Json.encodePrettily(DynamicClientRegistrationResponse.fromClient(client))) , error -> context.fail(error) ); } DynamicClientRegistrationEndpoint(DynamicClientRegistrationService dcrService, ClientSyncService clientSyncService); @Override void handle(RoutingContext context);  }