@Test public void update_invalidResourceBody() { when(context.getBodyAsJson()).thenReturn(new JsonObject("{\"description\":\"mydescription\"}")); endpoint.update(context); verify(context).fail(errCaptor.capture()); Assert.assertTrue(errCaptor.getValue() instanceof InvalidRequestException); }
public void update(RoutingContext context) { JWT accessToken = context.get(OAuth2AuthHandler.TOKEN_CONTEXT_KEY); Client client = context.get(OAuth2AuthHandler.CLIENT_CONTEXT_KEY); String resource_id = context.request().getParam(RESOURCE_ID); this.extractRequest(context) .flatMap(request -> this.resourceService.update(request, domain.getId(), client.getId(), accessToken.getSub(), resource_id)) .subscribe( resource -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.OK_200) .end(Json.encodePrettily(ResourceResponse.from(resource))) , error -> context.fail(error) ); }
ResourceRegistrationEndpoint implements Handler<RoutingContext> { public void update(RoutingContext context) { JWT accessToken = context.get(OAuth2AuthHandler.TOKEN_CONTEXT_KEY); Client client = context.get(OAuth2AuthHandler.CLIENT_CONTEXT_KEY); String resource_id = context.request().getParam(RESOURCE_ID); this.extractRequest(context) .flatMap(request -> this.resourceService.update(request, domain.getId(), client.getId(), accessToken.getSub(), resource_id)) .subscribe( resource -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.OK_200) .end(Json.encodePrettily(ResourceResponse.from(resource))) , error -> context.fail(error) ); } }
ResourceRegistrationEndpoint implements Handler<RoutingContext> { public void update(RoutingContext context) { JWT accessToken = context.get(OAuth2AuthHandler.TOKEN_CONTEXT_KEY); Client client = context.get(OAuth2AuthHandler.CLIENT_CONTEXT_KEY); String resource_id = context.request().getParam(RESOURCE_ID); this.extractRequest(context) .flatMap(request -> this.resourceService.update(request, domain.getId(), client.getId(), accessToken.getSub(), resource_id)) .subscribe( resource -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.OK_200) .end(Json.encodePrettily(ResourceResponse.from(resource))) , error -> context.fail(error) ); } ResourceRegistrationEndpoint(Domain domain, ResourceService resourceService); }
ResourceRegistrationEndpoint implements Handler<RoutingContext> { public void update(RoutingContext context) { JWT accessToken = context.get(OAuth2AuthHandler.TOKEN_CONTEXT_KEY); Client client = context.get(OAuth2AuthHandler.CLIENT_CONTEXT_KEY); String resource_id = context.request().getParam(RESOURCE_ID); this.extractRequest(context) .flatMap(request -> this.resourceService.update(request, domain.getId(), client.getId(), accessToken.getSub(), resource_id)) .subscribe( resource -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.OK_200) .end(Json.encodePrettily(ResourceResponse.from(resource))) , error -> context.fail(error) ); } ResourceRegistrationEndpoint(Domain domain, ResourceService resourceService); @Override void handle(RoutingContext context); void create(RoutingContext context); void get(RoutingContext context); void update(RoutingContext context); void delete(RoutingContext context); }
ResourceRegistrationEndpoint implements Handler<RoutingContext> { public void update(RoutingContext context) { JWT accessToken = context.get(OAuth2AuthHandler.TOKEN_CONTEXT_KEY); Client client = context.get(OAuth2AuthHandler.CLIENT_CONTEXT_KEY); String resource_id = context.request().getParam(RESOURCE_ID); this.extractRequest(context) .flatMap(request -> this.resourceService.update(request, domain.getId(), client.getId(), accessToken.getSub(), resource_id)) .subscribe( resource -> context.response() .putHeader(HttpHeaders.CACHE_CONTROL, "no-store") .putHeader(HttpHeaders.PRAGMA, "no-cache") .putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .setStatusCode(HttpStatusCode.OK_200) .end(Json.encodePrettily(ResourceResponse.from(resource))) , error -> context.fail(error) ); } ResourceRegistrationEndpoint(Domain domain, ResourceService resourceService); @Override void handle(RoutingContext context); void create(RoutingContext context); void get(RoutingContext context); void update(RoutingContext context); void delete(RoutingContext context);  }