Source:
<code>private Map<String, String> streamAllData(final List<TestStreamingClient> clients, final int totalEvents) throws InterruptedException { final Map<String, Integer> clientsBatchCount = new HashMap<>(); final Map<String, String> events = new HashMap<>(); while (events.size() < totalEvents) { Thread.sleep(100); clients.forEach(client -> { final List<StreamBatch> batches = client.getBatches(); if (!batches.isEmpty()) { if (!clientsBatchCount.containsKey(client.getSessionId())) { clientsBatchCount.put(client.getSessionId(), 0); } final int batchesReceived = batches.size(); final List<StreamBatch> addedBatches = batches.subList( clientsBatchCount.get(client.getSessionId()), batchesReceived); final int eventsInClient = batches.stream().mapToInt(b -> b.getEvents().size()).sum(); if (!addedBatches.isEmpty() && eventsInClient > 0) { try { final Map<String, List<SubscriptionCursor>> cursors = addedBatches.stream() .filter(batch -> !batch.getCursor().getOffset().equals("BEGIN")) .map(StreamBatch::getCursor).collect( Collectors.groupingBy(c -> c.getEventType() + "_" + c.getPartition())); cursors.values().forEach(joinedCursors -> joinedCursors.sort( <START> Comparator.comparing(f -> -Integer.valueOf(f.getOffset())))); <END> NakadiTestUtils.commitCursors( client.getSubscriptionId(), cursors.values().stream().map(c -> c.get(0)).collect(Collectors.toList()), client.getSessionId()); clientsBatchCount.put(client.getSessionId(), batchesReceived); addedBatches.stream() .flatMap(batch -> batch.getEvents().stream()) .forEach(evt -> { final String foo = (String) evt.get("foo"); Assert.assertFalse(events.containsKey(foo)); events.put(foo, client.getSessionId()); }); } catch (JsonProcessingException ex) { throw new RuntimeException(ex); } } } }); } return events; }</code><technical_language>is this for</technical_language>

Target:
private Map<String, String> streamAllData(final List<TestStreamingClient> clients, final int totalEvents) throws InterruptedException { final Map<String, Integer> clientsBatchCount = new HashMap<>(); final Map<String, String> events = new HashMap<>(); while (events.size() < totalEvents) { Thread.sleep(100); clients.forEach(client -> { final List<StreamBatch> batches = client.getBatches(); if (!batches.isEmpty()) { if (!clientsBatchCount.containsKey(client.getSessionId())) { clientsBatchCount.put(client.getSessionId(), 0); } final int batchesReceived = batches.size(); final List<StreamBatch> addedBatches = batches.subList( clientsBatchCount.get(client.getSessionId()), batchesReceived); final int eventsInClient = batches.stream().mapToInt(b -> b.getEvents().size()).sum(); if (!addedBatches.isEmpty() && eventsInClient > 0) { try { final Map<String, List<SubscriptionCursor>> cursors = addedBatches.stream() .filter(batch -> !batch.getCursor().getOffset().equals("BEGIN")) .map(StreamBatch::getCursor).collect( Collectors.groupingBy(c -> c.getEventType() + "_" + c.getPartition())); cursors.values().forEach(joinedCursors -> joinedCursors.sort( Comparator.comparing(f -> Integer.valueOf(f.getOffset())))); NakadiTestUtils.commitCursors( client.getSubscriptionId(), cursors.values().stream().map(c -> c.get(0)).collect(Collectors.toList()), client.getSessionId()); clientsBatchCount.put(client.getSessionId(), batchesReceived); addedBatches.stream() .flatMap(batch -> batch.getEvents().stream()) .forEach(evt -> { final String foo = (String) evt.get("foo"); Assert.assertFalse(events.containsKey(foo)); events.put(foo, client.getSessionId()); }); } catch (JsonProcessingException ex) { throw new RuntimeException(ex); } } } }); } return events; }