Skip to content

Commit

Permalink
Merge pull request eugenp#10006 from Sebassllr/feature/BAEL-4387
Browse files Browse the repository at this point in the history
  • Loading branch information
bfontana authored Sep 12, 2020
2 parents 22fba25 + 2b658ea commit 7e013c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions java-collections-conversions-2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
</parent>

<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.17.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.baeldung.arrayconversion;

import org.assertj.core.api.ListAssert;
import org.hamcrest.CoreMatchers;
import org.junit.Test;

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 {

Expand All @@ -17,8 +17,8 @@ public void givenAnArray_whenConvertingToList_returnUnmodifiableListUnitTest() {
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");
}

Expand All @@ -27,9 +27,9 @@ public void givenAnArray_whenConvertingToList_returnModifiableListUnitTest() {
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");
}
}

0 comments on commit 7e013c7

Please sign in to comment.