@Test public void create() { String url = "www.testLong.org"; String userId = UUID.randomUUID().toString(); CreateShortener request = CreateShortener.builder() .url(url) .userId(userId) .build(); ShortenerDto result = webTestClient.post().uri("/shorteners") .contentType(MediaType.APPLICATION_JSON) .body(BodyInserters.fromValue(request)) .exchange() .expectHeader().contentType(MediaType.APPLICATION_JSON) .expectBody(ShortenerDto.class).returnResult().getResponseBody(); assertTrue(result.url().equals(url)); assertFalse(result.key().isEmpty()); assertTrue(!result.id().isEmpty()); }
Mono<ServerResponse> create(ServerRequest request) { log.info("execute() -> "); return request.bodyToMono(CreateShortener.class) .flatMap(shortenerService::create) .flatMap(this::mapToResponse); }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> create(ServerRequest request) { log.info("execute() -> "); return request.bodyToMono(CreateShortener.class) .flatMap(shortenerService::create) .flatMap(this::mapToResponse); } }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> create(ServerRequest request) { log.info("execute() -> "); return request.bodyToMono(CreateShortener.class) .flatMap(shortenerService::create) .flatMap(this::mapToResponse); } ShortenerHandler(ShortenerService shortenerService, ShortenerQuery shortenerQuery); }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> create(ServerRequest request) { log.info("execute() -> "); return request.bodyToMono(CreateShortener.class) .flatMap(shortenerService::create) .flatMap(this::mapToResponse); } ShortenerHandler(ShortenerService shortenerService, ShortenerQuery shortenerQuery); @Override RouterFunction<ServerResponse> route(); }
ShortenerHandler implements HttpHandler { Mono<ServerResponse> create(ServerRequest request) { log.info("execute() -> "); return request.bodyToMono(CreateShortener.class) .flatMap(shortenerService::create) .flatMap(this::mapToResponse); } ShortenerHandler(ShortenerService shortenerService, ShortenerQuery shortenerQuery); @Override RouterFunction<ServerResponse> route();  }