SplitUnitTest refactor
This commit is contained in:
parent
a5cd330ab7
commit
286c25555a
|
@ -2,11 +2,10 @@ package com.baeldung.string;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.assertj.core.util.Lists;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class SplitUnitTest {
|
||||||
public void givenString_whenSplit_thenReturnsIterable_Splitter() {
|
public void givenString_whenSplit_thenReturnsIterable_Splitter() {
|
||||||
//given
|
//given
|
||||||
Iterable<String> result = Splitter.on(',').trimResults().omitEmptyStrings().split("car,jeep,, scooter");
|
Iterable<String> result = Splitter.on(',').trimResults().omitEmptyStrings().split("car,jeep,, scooter");
|
||||||
List<String> resultList = StreamSupport.stream(result.spliterator(), false).collect(Collectors.toList());
|
List<String> resultList = Lists.newArrayList(result);
|
||||||
|
|
||||||
assertThat(resultList)
|
assertThat(resultList)
|
||||||
.containsExactly("car", "jeep", "scooter");
|
.containsExactly("car", "jeep", "scooter");
|
||||||
|
|
Loading…
Reference in New Issue