mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
create test for metastring
This commit is contained in:
1 parent
73fd1c9edd
commit
57658d2268
3 files changed
+32
-2
No files matched your search
@@ -6,6 +6,7 @@ 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.MetaListLikePreprocessor;
|
import com.dfsek.terra.config.preprocessor.MetaListLikePreprocessor;
|
||||||
import com.dfsek.terra.config.preprocessor.MetaMapPreprocessor;
|
import com.dfsek.terra.config.preprocessor.MetaMapPreprocessor;
|
||||||
|
import com.dfsek.terra.config.preprocessor.MetaStringPreprocessor;
|
||||||
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;
|
||||||
|
|
||||||
@@ -59,4 +60,28 @@ public class MetaTest {
|
|||||||
@Value("map")
|
@Value("map")
|
||||||
private @Meta Map<@Meta String, @Meta String> map;
|
private @Meta Map<@Meta String, @Meta String> map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMetaString() {
|
||||||
|
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 MetaListLikePreprocessor(configurationMap));
|
||||||
|
loader.registerPreprocessor(Meta.class, new MetaMapPreprocessor(configurationMap));
|
||||||
|
loader.registerPreprocessor(Meta.class, new MetaStringPreprocessor(configurationMap));
|
||||||
|
|
||||||
|
System.out.println(loader.load(new MetaStringConfig(), meta).string);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class MetaStringConfig implements ConfigTemplate {
|
||||||
|
@Value("string")
|
||||||
|
private @Meta String string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,4 +12,5 @@ map:
|
|||||||
- metaTarget.yml:map1
|
- metaTarget.yml:map1
|
||||||
- metaTarget.yml:map2
|
- metaTarget.yml:map2
|
||||||
one: ONE
|
one: ONE
|
||||||
two: TWO
|
two: TWO
|
||||||
|
string: "one-${metaTarget.yml:string.two}-${metaTarget.yml:string.three}-four-five-${metaTarget.yml:string.six}"
|
||||||
@@ -9,4 +9,8 @@ map1:
|
|||||||
four: FOUR
|
four: FOUR
|
||||||
five: FIVE
|
five: FIVE
|
||||||
map2:
|
map2:
|
||||||
six: SIX
|
six: SIX
|
||||||
|
string:
|
||||||
|
two: two
|
||||||
|
three: three
|
||||||
|
six: six
|
||||||
Reference in new issue
Block a user