mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
create test for MetaMap
This commit is contained in:
parent
d0434ef05e
commit
5a8f5aa29c
@ -5,6 +5,7 @@ import com.dfsek.tectonic.loading.ConfigLoader;
|
|||||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
import com.dfsek.terra.config.preprocessor.MetaListPreprocessor;
|
import com.dfsek.terra.config.preprocessor.MetaListPreprocessor;
|
||||||
|
import com.dfsek.terra.config.preprocessor.MetaMapPreprocessor;
|
||||||
import com.dfsek.terra.config.preprocessor.MetaValuePreprocessor;
|
import com.dfsek.terra.config.preprocessor.MetaValuePreprocessor;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@ -26,12 +27,36 @@ public class MetaTest {
|
|||||||
ConfigLoader loader = new ConfigLoader();
|
ConfigLoader loader = new ConfigLoader();
|
||||||
loader.registerPreprocessor(Meta.class, new MetaValuePreprocessor(configurationMap));
|
loader.registerPreprocessor(Meta.class, new MetaValuePreprocessor(configurationMap));
|
||||||
loader.registerPreprocessor(Meta.class, new MetaListPreprocessor(configurationMap));
|
loader.registerPreprocessor(Meta.class, new MetaListPreprocessor(configurationMap));
|
||||||
|
loader.registerPreprocessor(Meta.class, new MetaMapPreprocessor(configurationMap));
|
||||||
|
|
||||||
loader.load(new ConfigTest(), meta).list.forEach(System.out::println);
|
loader.load(new MetaListConfig(), meta).list.forEach(System.out::println);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ConfigTest implements ConfigTemplate {
|
private static final class MetaListConfig implements ConfigTemplate {
|
||||||
@Value("list")
|
@Value("list")
|
||||||
private @Meta List<@Meta String> list;
|
private @Meta List<@Meta String> list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMetaMap() {
|
||||||
|
Configuration meta = new YamlConfiguration(MetaTest.class.getResourceAsStream("/meta.yml"), "meta.yml");
|
||||||
|
Configuration metaTarget = new YamlConfiguration(MetaTest.class.getResourceAsStream("/metaTarget.yml"), "metaTarget.yml");
|
||||||
|
|
||||||
|
Map<String, Configuration> configurationMap = new HashMap<>();
|
||||||
|
|
||||||
|
configurationMap.put(meta.getName(), meta);
|
||||||
|
configurationMap.put(metaTarget.getName(), metaTarget);
|
||||||
|
|
||||||
|
ConfigLoader loader = new ConfigLoader();
|
||||||
|
loader.registerPreprocessor(Meta.class, new MetaValuePreprocessor(configurationMap));
|
||||||
|
loader.registerPreprocessor(Meta.class, new MetaListPreprocessor(configurationMap));
|
||||||
|
loader.registerPreprocessor(Meta.class, new MetaMapPreprocessor(configurationMap));
|
||||||
|
|
||||||
|
loader.load(new MetaMapConfig(), meta).map.forEach((k, v) -> System.out.println(k + ": " + v));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class MetaMapConfig implements ConfigTemplate {
|
||||||
|
@Value("map")
|
||||||
|
private @Meta Map<@Meta String, @Meta String> map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,3 +7,9 @@ list:
|
|||||||
- "<< metaTarget.yml:list2"
|
- "<< metaTarget.yml:list2"
|
||||||
- NINE
|
- NINE
|
||||||
- TEN
|
- TEN
|
||||||
|
map:
|
||||||
|
"<<":
|
||||||
|
- metaTarget.yml:map1
|
||||||
|
- metaTarget.yml:map2
|
||||||
|
one: ONE
|
||||||
|
two: TWO
|
@ -4,3 +4,9 @@ list:
|
|||||||
list2:
|
list2:
|
||||||
- SEVEN
|
- SEVEN
|
||||||
- EIGHT
|
- EIGHT
|
||||||
|
map1:
|
||||||
|
three: THREE
|
||||||
|
four: FOUR
|
||||||
|
five: FIVE
|
||||||
|
map2:
|
||||||
|
six: SIX
|
Loading…
x
Reference in New Issue
Block a user