@WithSpan
    @Override
    public SearchResponse apply(SearchResponse searchResponse) {
        final List<ResultMessageSummary> summaries = searchResponse.messages().stream()
                .map(summary -> {
                    if (requireAllFields && !usedVariables.stream().allMatch(variable -> summary.message().containsKey(variable.name))) {
                        return summary;
                    }
                    final String formattedString = template.transform(summary.message(), Locale.ENGLISH);

                    if (formattedString == null) {
                        return summary;
                    }

                    final Message message = messageFactory.createMessage(ImmutableMap.copyOf(summary.message()));
                    message.addField(targetField, formattedString);
                    return summary.toBuilder().message(message.getFields()).build();
                })
                .collect(Collectors.toList());

        return searchResponse.toBuilder().messages(summaries).build();
    }
@Test
    public void formatAllowEmptyValues() {
        final DecoratorImpl decorator = getDecoratorConfig("${field_a}: ${field_b}", "message", false);

        final FormatStringDecorator formatStringDecorator = new FormatStringDecorator(decorator, templateEngine, messageFactory);
        final SearchResponse searchResponse = getSearchResponse();

        final SearchResponse response = formatStringDecorator.apply(searchResponse);

        assertThat(response.messages().size()).isEqualTo(4);
        assertThat(response.messages().get(0).message().get("message")).isEqualTo("1: b");
        assertThat(response.messages().get(1).message().get("message")).isEqualTo("1:");
        assertThat(response.messages().get(2).message().get("message")).isEqualTo(": b");
        assertThat(response.messages().get(3).message().get("message")).isEqualTo(":");
    }