@Override
    public Mono<ServerResponse> handle(ServerRequest request) {
        String name = request.pathVariable("name");
        return request.bodyToMono(Unstructured.class)
            .filter(unstructured -> unstructured.getMetadata() != null
                && StringUtils.hasText(unstructured.getMetadata().getName())
                && Objects.equals(unstructured.getMetadata().getName(), name))
            .switchIfEmpty(Mono.error(() -> new ServerWebInputException(
                "Cannot read body to " + scheme.groupVersionKind())))
            .flatMap(client::update)
            .flatMap(updated -> ServerResponse
                .ok()
                .contentType(MediaType.APPLICATION_JSON)
                .bodyValue(updated));
    }
@Test
    void shouldHandleCorrectly() {
        final var fake = new FakeExtension();
        var metadata = new Metadata();
        metadata.setName("my-fake");
        fake.setMetadata(metadata);

        var unstructured = new Unstructured();
        unstructured.setMetadata(metadata);
        unstructured.setApiVersion("fake.halo.run/v1alpha1");
        unstructured.setKind("Fake");

        var serverRequest = MockServerRequest.builder()
            .pathVariable("name", "my-fake")
            .body(Mono.just(unstructured));
        // when(client.fetch(eq(FakeExtension.class), eq("my-fake"))).thenReturn(Mono.just(fake));
        when(client.update(eq(unstructured))).thenReturn(Mono.just(unstructured));

        var scheme = Scheme.buildFromType(FakeExtension.class);
        var updateHandler = new ExtensionUpdateHandler(scheme, client);
        var responseMono = updateHandler.handle(serverRequest);

        StepVerifier.create(responseMono)
            .assertNext(response -> {
                assertEquals(HttpStatus.OK, response.statusCode());
                assertEquals(MediaType.APPLICATION_JSON, response.headers().getContentType());
                assertTrue(response instanceof EntityResponse<?>);
                assertEquals(unstructured, ((EntityResponse<?>) response).entity());
            })
            .verifyComplete();
        // verify(client, times(1)).fetch(eq(FakeExtension.class), eq("my-fake"));
        verify(client, times(1)).update(eq(unstructured));
    }