### Question:
ConfigMapperManager implements ConfigMapper { Config simpleConfig(String name, String stringValue) { return new SingleValueConfigImpl(this, name, stringValue); } ConfigMapperManager(MapperProviders mapperProviders); @Override T map(Config config, Class<T> type); @Override T map(Config config, GenericType<T> type); @Override T map(String value, Class<T> type, String key); @Override T map(String value, GenericType<T> type, String key); @SuppressWarnings("unchecked") static Class<T> supportedType(Class<T> type);  }### Answer:
@Test void testSingleValueConfigImpl() { Config config = managerNoServices.simpleConfig("key1", "42"); assertThat(config.key(), is(Config.Key.create("key1"))); assertThat(config.asString(), is(ConfigValues.simpleValue("42"))); assertThat(config.type(), is(Config.Type.VALUE)); assertThat(config.timestamp(), not(nullValue())); { Config sub = config.get("sub"); assertThat(sub.key(), is(Config.Key.create("key1.sub"))); assertThat(sub.asString(), is(ConfigValues.empty())); assertThat(sub.type(), is(Config.Type.MISSING)); } { Config detached = config.detach(); assertThat(detached.key(), is(Config.Key.create(""))); assertThat(detached.asString(), is(ConfigValues.simpleValue("42"))); assertThat(detached.type(), is(Config.Type.VALUE)); } assertThat(config.traverse().collect(Collectors.toList()), empty()); { Map<String, String> map = config.asMap().get(); assertThat(map.entrySet(), hasSize(1)); assertThat(map, hasEntry("key1", "42")); } assertThat(config.as(Integer.class).get(), is(42)); assertThat(config.asNodeList().get(), is(List.of(config))); assertThat(config.asList(String.class).get(), is(List.of("42"))); Config.Context context = config.context(); assertThat(context.timestamp(), is(config.timestamp())); assertThat(context.reload(), sameInstance(config)); assertThat(context.last(), sameInstance(config)); }
@Test void testGenericTypeMapperMap() { MapperProviders providers = MapperProviders.create(); providers.add(new ParametrizedConfigMapper()); ConfigMapperManager configMapperManager = BuilderImpl.buildMappers(providers); Config config = configMapperManager.simpleConfig("test", "1"); ConfigValue<Map<String, Integer>> map = config.as(new GenericType<Map<String, Integer>>() { }); assertThat(map.get(), is(Map.of("test", 1))); }
@Test void testGenericTypeMapperList() { MapperProviders providers = MapperProviders.create(); providers.add(new ParametrizedConfigMapper()); ConfigMapperManager configMapperManager = BuilderImpl.buildMappers(providers); Config config = configMapperManager.simpleConfig("test", "1"); ConfigValue<Map<String, List<Integer>>> map = config.as(new GenericType<Map<String, List<Integer>>>() { }); assertThat(map.get(), is(Map.of("test", List.of(1)))); }