Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public void setLineSeparator(String lineSeparator) {

@Override
public String aggregate(Collection<T> items) {
if (items.isEmpty()) {
return "";
}
StringBuilder builder = new StringBuilder();
for (T value : items) {
builder.append(delegate.aggregate(value)).append(lineSeparator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.junit.jupiter.api.Test;

import org.springframework.batch.infrastructure.item.file.transform.RecursiveCollectionLineAggregator;
import org.springframework.util.StringUtils;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -34,6 +33,12 @@ class RecursiveCollectionLineAggregatorTests {

private final RecursiveCollectionLineAggregator<String> aggregator = new RecursiveCollectionLineAggregator<>();

@Test
void testSetDelegateAndPassEmptyCollection() {
aggregator.setDelegate(item -> "bar");
assertEquals("", aggregator.aggregate(Collections.emptyList()));
}

@Test
void testSetDelegateAndPassInString() {
aggregator.setDelegate(item -> "bar");
Expand Down