use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.
the class DslDefinitionRuleTest method test1.
@Test
public void test1() throws PegNoMatchFoundException {
final DslDefinition dslDefinition = new DslDynamicDefinitionRule("create", dslDefinitionRepository.getGrammar()).parse("create Formatter FMT_TEST { args : \"UPPER\" }", 0).getValue();
Assert.assertNotNull(dslDefinition);
}
use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.
the class DslDefinitionRuleTest method test2.
// Exemple de test sur la déclaration d'un Domain
// create Domain DO_CODE_POSTAL (
// dataType : String;
// formatter : FMT_DEFAULT;
// constraint : {CK_CODE_POSTAL}
// )
@Test
public void test2() throws PegNoMatchFoundException {
final DslDefinition dslDefinition = new DslDynamicDefinitionRule("create", dslDefinitionRepository.getGrammar()).parse("create Domain DO_CODE_POSTAL { dataType : String , formatter:FMT_DEFAULT, constraint : [ CK_CODE_POSTAL ] } ", 0).getValue();
Assert.assertNotNull(dslDefinition);
}
use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.
the class EnvironmentManagerTest method badTypeTest.
@Test
public void badTypeTest() {
Assertions.assertThrows(ClassCastException.class, () -> {
final DslDefinition address1Definition = DslDefinition.builder("MOCK_MAIN_ADDRESS", PersonGrammar.ADDRESS_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(STREET, "1, rue du louvre").addPropertyValue(POSTAL_CODE, 75008).addPropertyValue(CITY, "Paris").build();
dslDefinitionRepository.addDefinition(address1Definition);
});
}
use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.
the class EnvironmentManagerTest method simpleTest.
@Test
public void simpleTest() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final DslDefinition address1Definition = DslDefinition.builder("MOCK_MAIN_ADDRESS", PersonGrammar.ADDRESS_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(STREET, "1, rue du louvre").addPropertyValue(POSTAL_CODE, "75008").addPropertyValue(CITY, "Paris").build();
dslDefinitionRepository.addDefinition(address1Definition);
final DslDefinition address2Definition = DslDefinition.builder("MOCK_SECOND_ADDRESS", PersonGrammar.ADDRESS_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(STREET, "105, rue martin").addPropertyValue(POSTAL_CODE, "75008").addPropertyValue(CITY, "Paris CEDEX").build();
dslDefinitionRepository.addDefinition(address2Definition);
final DslDefinition personDefinition = DslDefinition.builder("MOCK_MISTER_BEAN", PersonGrammar.PERSON_ENTITY).withPackageName("io.vertigo.test.model").addPropertyValue(NAME, "105, rue martin").addPropertyValue(FIRST_NAME, "75008").addPropertyValue(AGE, 42).addPropertyValue(HEIGHT, 175.0d).addPropertyValue(MALE, Boolean.TRUE).addDefinitionLink(MAIN_ADDRESS, "MOCK_MAIN_ADDRESS").addDefinitionLink(PersonGrammar.SECOND_ADDRESS, "MOCK_SECOND_ADDRESS").build();
dslDefinitionRepository.addDefinition(personDefinition);
dslDefinitionRepository.solve(definitionSpace);
assertNotNull(personDefinition);
}
use of io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition in project vertigo by KleeGroup.
the class DynamoDefinitionProvider method parse.
/**
* @param definitionResourceConfigs List of resources (must be in a type managed by this loader)
*/
private List<DefinitionSupplier> parse(final DefinitionSpace definitionSpace) {
// Création du repositoy des instances le la grammaire (=> model)
final DynamicRegistry dynamoDynamicRegistry = new DynamoDynamicRegistry();
final DslDefinitionRepository dslDefinitionRepository = new DslDefinitionRepository(dynamoDynamicRegistry);
// --Enregistrement des types primitifs
for (final DslDefinition dslDefinition : dynamoDynamicRegistry.getGrammar().getRootDefinitions()) {
dslDefinitionRepository.addDefinition(dslDefinition);
}
for (final DefinitionResourceConfig definitionResourceConfig : definitionResourceConfigs) {
final Loader loaderPlugin = loadersByType.get(definitionResourceConfig.getType());
Assertion.checkNotNull(loaderPlugin, "This resource {0} can not be parse by these loaders : {1}", definitionResourceConfig, loadersByType.keySet());
loaderPlugin.load(definitionResourceConfig.getPath(), dslDefinitionRepository);
}
return dslDefinitionRepository.solve(definitionSpace);
}
Aggregations