private static String formatAssignment(Map<String, Collection<String>> assignment) {
        StringBuilder result = new StringBuilder();
        for (String worker : assignment.keySet().stream().sorted().collect(Collectors.toList())) {
            result.append(String.format("\n%s=%s", worker, assignment.getOrDefault(worker,
                    Collections.emptyList())));
        }
        return result.toString();
    }
Integration tests for incremental cooperative rebalancing between Connect workers
connect/runtime/src/test/java/org/apache/kafka/connect/integration/RebalanceSourceConnectorsIntegrationTest.java