@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 shouldReturnErrorWhenExtensionNotFound() {
        final var unstructured = new Unstructured();
        var metadata = new Metadata();
        metadata.setName("my-fake");
        unstructured.setMetadata(metadata);
        unstructured.setApiVersion("fake.halo.run/v1alpha1");
        unstructured.setKind("Fake");

        var serverRequest = MockServerRequest.builder()
            .pathVariable("name", "my-fake")
            .body(Mono.just(unstructured));
        doThrow(ExtensionNotFoundException.class).when(client).update(any());

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

        StepVerifier.create(responseMono)
            .verifyError(ExtensionNotFoundException.class);

        verify(client, times(1)).update(
            argThat(extension -> Objects.equals("my-fake", extension.getMetadata().getName())));
        verify(client, times(0)).fetch(same(FakeExtension.class), anyString());
    }