Last active
June 21, 2023 12:14
-
-
Save pawellabaj/4f1dff142391a709c13e847f4420fa91 to your computer and use it in GitHub Desktop.
Without looking into a documentation, will the test pass or fail?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.jupiter.api.Test; | |
import java.util.LinkedHashSet; | |
import java.util.Set; | |
import static org.assertj.core.api.Assertions.assertThat; | |
class OrderSetTest { | |
@Test | |
void orderInSetShouldNotBeLost() { | |
//given | |
var insertionOrderedSet = new LinkedHashSet<String>(); | |
insertionOrderedSet.add("C"); | |
insertionOrderedSet.add("B"); | |
insertionOrderedSet.add("A"); | |
// when | |
var immutableSet = Set.copyOf(insertionOrderedSet); | |
// then | |
assertThat(immutableSet).containsExactly("C", "B", "A"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment