Update Print2DArraysUnitTest.java
This commit is contained in:
parent
5f0cc26b40
commit
8c9636c5c6
@ -1,17 +1,19 @@
|
||||
package com.baeldung.print2darrays;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import uk.org.webcompere.systemstubs.jupiter.SystemStub;
|
||||
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
|
||||
import uk.org.webcompere.systemstubs.stream.SystemOut;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(SystemStubsExtension.class)
|
||||
public class Print2DArraysUnitTest {
|
||||
|
||||
@SystemStub
|
||||
private SystemOut systemOut;
|
||||
|
||||
@ -31,7 +33,9 @@ public class Print2DArraysUnitTest {
|
||||
@Test
|
||||
public void whenPrint2dArrayUsingStreams_thenLinesAreWrittenToSystemOut() {
|
||||
int[][] myArray = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
|
||||
Arrays.stream(myArray) .flatMapToInt(Arrays::stream) .forEach(num -> System.out.print(num + " "));
|
||||
Arrays.stream(myArray)
|
||||
.flatMapToInt(Arrays::stream)
|
||||
.forEach(num -> System.out.print(num + " "));
|
||||
String expectedOutput = "1 2 3 4 5 6 7 8 9 ";
|
||||
assertThat(systemOut.getLines()).containsExactly(expectedOutput);
|
||||
}
|
||||
@ -54,4 +58,3 @@ public class Print2DArraysUnitTest {
|
||||
assertThat(systemOut.getLines()).containsExactly(expectedOutput);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user