BAEL-4387 Add AssertJ assertions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.baeldung.arrayconversion;
|
||||
|
||||
import org.assertj.core.api.ListAssert;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -7,8 +8,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ArrayToListConversionUnitTest {
|
||||
|
||||
@@ -17,8 +17,8 @@ public class ArrayToListConversionUnitTest {
|
||||
String[] stringArray = new String[] { "A", "B", "C", "D" };
|
||||
List<String> stringList = Arrays.asList(stringArray);
|
||||
stringList.set(0, "E");
|
||||
assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D"));
|
||||
assertArrayEquals(stringArray, new String[] { "E", "B", "C", "D" });
|
||||
assertThat(stringList).containsExactly("E", "B", "C", "D");
|
||||
assertThat(stringArray).containsExactly("E", "B", "C", "D");
|
||||
stringList.add("F");
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ public class ArrayToListConversionUnitTest {
|
||||
String[] stringArray = new String[] { "A", "B", "C", "D" };
|
||||
List<String> stringList = new ArrayList<>(Arrays.asList(stringArray));
|
||||
stringList.set(0, "E");
|
||||
assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D"));
|
||||
assertArrayEquals(stringArray, new String[] { "A", "B", "C", "D" });
|
||||
assertThat(stringList).containsExactly("E", "B", "C", "D");
|
||||
assertThat(stringArray).containsExactly("A", "B", "C", "D");
|
||||
stringList.add("F");
|
||||
assertThat(stringList, CoreMatchers.hasItems("E", "B", "C", "D", "F"));
|
||||
assertThat(stringList).containsExactly("E", "B", "C", "D", "F");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user