@Override
    public void run(T configuration, Environment environment) throws Exception {
        final Map<String, Map<String, String>> options = getViewConfiguration(configuration);
        for (ViewRenderer viewRenderer : viewRenderers) {
            final Map<String, String> viewOptions = options.get(viewRenderer.getConfigurationKey());
            viewRenderer.configure(viewOptions == null ? Map.of() : viewOptions);
        }
        environment.jersey().register(new ViewMessageBodyWriter(environment.metrics(), viewRenderers));
    }
@Test
    void addsTheViewMessageBodyWriterWithSingleViewRendererToTheEnvironment() throws Exception {
        final String configurationKey = "freemarker";
        final String testKey = "testKey";
        final Map<String, String> freeMarkerConfig = Collections.singletonMap(testKey, "yes");
        final Map<String, Map<String, String>> viewRendererConfig = Collections.singletonMap(configurationKey, freeMarkerConfig);

        final MyConfiguration myConfiguration = new MyConfiguration();
        myConfiguration.setViewRendererConfiguration(viewRendererConfig);

        ViewRenderer renderer = new ViewRenderer() {
            @Override
            public boolean isRenderable(View view) {
                return false;
            }

            @Override
            public void render(View view, Locale locale, OutputStream output) throws WebApplicationException {
                //nothing to do
            }

            @Override
            public void configure(Map<String, String> options) {
                assertThat(options).containsKey(testKey);
            }

            @Override
            public String getConfigurationKey() {
                return configurationKey;
            }
        };

        new ViewBundle<MyConfiguration>(Collections.singletonList(renderer)) {
            @Override
            public Map<String, Map<String, String>> getViewConfiguration(MyConfiguration configuration) {
                return configuration.getViewRendererConfiguration();
            }
        }.run(myConfiguration, environment);

        final ArgumentCaptor<ViewMessageBodyWriter> captor = ArgumentCaptor.forClass(ViewMessageBodyWriter.class);
        verify(jerseyEnvironment).register(captor.capture());

        final ViewMessageBodyWriter capturedRenderer = captor.getValue();
        assertThat(capturedRenderer.getRenderers())
            .hasSize(1)
            .contains(renderer);
    }