### Question:
CompoundParams implements javax0.geci.api.CompoundParams { @Override public String get(String key, String defaults) { return Optional.ofNullable(get0(key)).orElse(defaults); } @SafeVarargs  CompoundParams(String id, Map<String, ?>... params);  CompoundParams(CompoundParams... cparams); void trace(); @Override void setConstraints(Source source, String mnemonic, Set<String> allowedKeys); @Override String get(String key, String defaults); @Override String get(String key, Supplier<String> defaultSupplier); @Override String get(String key); @Override String id(String mnemonic); @Override List<String> getValueList(String key, List<String> defaults); @Override List<String> getValueList(String key); @Override boolean is(String key); @Override boolean is(String key, boolean defaultValue); @Override boolean is(String key, String defaultValue); @Override Set<String> keySet(); @Override String toString();  }### Answer:
@Test @DisplayName("It proxies multiple CompoundParameters with possible null Co..Pa..ms") void testFromMapMultipleCompoundWithNull() { final var sut = new CompoundParams( null, new CompoundParams("theId", JVM8Tools.asMap("a", "1", "b", "2")), new CompoundParams("otherID-no one cares", JVM8Tools.asMap("a", "4", "b", "4", "c", "5")) ); Assertions.assertEquals("theId", sut.get("id")); Assertions.assertEquals("1", sut.get("a")); Assertions.assertEquals("2", sut.get("b")); Assertions.assertEquals("5", sut.get("c")); Assertions.assertEquals("", sut.get("nonexsistent")); }
@Test @DisplayName("Get returns with value if key exists or default value or supplied value") void testGet() { final var sut = new CompoundParams("theId"); Assertions.assertEquals("theId", sut.get("id")); Assertions.assertEquals("", sut.get("nonexistent")); Assertions.assertEquals("foo", sut.get("nonexistent", "foo")); Assertions.assertEquals("foobar", sut.get("nonexistent", () -> "foo" + "bar")); }
@Test @DisplayName("It proxies a normal map") void testFromMap() { final var sut = new CompoundParams("theId", JVM8Tools.asMap("a", "1", "b", "2")); Assertions.assertEquals("theId", sut.get("id")); Assertions.assertEquals("1", sut.get("a")); Assertions.assertEquals("2", sut.get("b")); Assertions.assertEquals("", sut.get("nonexsistent")); }
@Test @DisplayName("It proxies multiple maps and earlier hides the later") void testFromMapMultiple() { final var sut = new CompoundParams("theId", JVM8Tools.asMap("a", "1", "b", "2"), JVM8Tools.asMap("a", "4", "b", "4", "c", "5")); Assertions.assertEquals("theId", sut.get("id")); Assertions.assertEquals("1", sut.get("a")); Assertions.assertEquals("2", sut.get("b")); Assertions.assertEquals("5", sut.get("c")); Assertions.assertEquals("", sut.get("nonexsistent")); }
@Test @DisplayName("It proxies multiple CompoundParameters and earlier hides the later") void testFromMapMultipleCompound() { final var sut = new CompoundParams( new CompoundParams("theId", JVM8Tools.asMap("a", "1", "b", "2")), new CompoundParams("otherID-no one cares", JVM8Tools.asMap("a", "4", "b", "4", "c", "5")) ); Assertions.assertEquals("theId", sut.get("id")); Assertions.assertEquals("1", sut.get("a")); Assertions.assertEquals("2", sut.get("b")); Assertions.assertEquals("5", sut.get("c")); Assertions.assertEquals("", sut.get("nonexsistent")); }