Skip to content

Commit

Permalink
Test MapWithDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Sep 18, 2024
1 parent 9e7c3e4 commit ecefcdc
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static io.smallrye.config.KeyValuesConfigSource.config;
import static io.smallrye.config.SmallRyeConfig.SMALLRYE_CONFIG_MAPPING_VALIDATE_UNKNOWN;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.HashMap;
Expand All @@ -13,6 +15,8 @@

import org.junit.jupiter.api.Test;

import io.smallrye.config.ConfigMappingContext.MapWithDefault;

public class ObjectCreatorTest {
@Test
void objectCreator() {
Expand Down Expand Up @@ -601,4 +605,21 @@ interface Nested extends NestedBase {
public interface ExtendsBase extends Base {

}

@SuppressWarnings({
"MismatchedQueryAndUpdateOfCollection",
"RedundantOperationOnEmptyContainer"
})
@Test
void mapWithDefault() {
MapWithDefault<String, String> map = new MapWithDefault<>("default");
assertTrue(map.isEmpty());
assertFalse(map.entrySet().iterator().hasNext());

assertEquals("default", map.get("default"));
assertEquals("default", map.get("one"));
assertEquals("default", map.get("two"));

assertNull(map.getOrDefault("default", null));
}
}

0 comments on commit ecefcdc

Please sign in to comment.