public String getMatchingEndpointsForExchangeByChannel(
            final Exchange exchange,
            final String channel,
            final boolean firstMatchOnly,
            final boolean warnDroppedMessage) {
        List<String> matchingEndpoints = new ArrayList<>();
        for (PrioritizedFilter filter : filterMap.get(channel)) {
            if (filter.predicate().matches(exchange)) {
                matchingEndpoints.add(filter.endpoint());
                filter.statistics().incrementCount();
                if (firstMatchOnly) {
                    break;
                }
            }
        }
        String recipients = String.join(",", matchingEndpoints);
        if (ObjectHelper.isEmpty(recipients)) {
            Message message = exchange.getMessage();
            message.setHeader(ORIGINAL_BODY_HEADER, message.getBody());
            recipients = String.format(DynamicRouterConstants.LOG_ENDPOINT, this.getClass().getCanonicalName(), channel,
                    warnDroppedMessage ? LoggingLevel.WARN : LoggingLevel.DEBUG);
            String error = String.format(
                    "DynamicRouter channel '%s': no filters matched for an exchange from route: '%s'.  " +
                                         "The 'originalBody' header contains the original message body.",
                    channel, exchange.getFromEndpoint());
            message.setBody(error, String.class);
        }
        return recipients;
    }
@Test
    void testGetMatchingEndpointsForExchangeByChannel() {
        String channel = "test";
        Mockito.when(prioritizedFilter.id()).thenReturn("id");
        Mockito.when(prioritizedFilter.priority()).thenReturn(1);
        Mockito.when(prioritizedFilter.predicate()).thenReturn(predicate);
        Mockito.when(prioritizedFilter.statistics()).thenReturn(prioritizedFilterStatistics);
        Mockito.when(prioritizedFilter.endpoint()).thenReturn("testEndpoint");
        Mockito.doNothing().when(prioritizedFilterStatistics).incrementCount();
        Mockito.when(predicate.matches(exchange)).thenReturn(true);
        filterService.addFilterForChannel(prioritizedFilter, DYNAMIC_ROUTER_CHANNEL, false);
        String result = filterService.getMatchingEndpointsForExchangeByChannel(exchange, channel, true, false);
        Assertions.assertEquals("testEndpoint", result);
    }