use of io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule in project vertigo by KleeGroup.
the class DslDefinitionBodyRuleTest 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 List<DslEntity> entities = dslDefinitionRepository.getGrammar().getEntities();
final DslEntity entity = find(entities, "Domain");
final DslDefinitionBody definitionBody = new DslDefinitionBodyRule(entity).parse("{ dataType : String , formatter : FMT_DEFAULT, constraint : [ CK_CODE_POSTAL ] } ", 0).getValue();
Assert.assertNotNull(definitionBody);
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule in project vertigo by KleeGroup.
the class DslDefinitionBodyRuleTest method test1.
@Test
public void test1() throws PegNoMatchFoundException {
final List<DslEntity> entities = dslDefinitionRepository.getGrammar().getEntities();
final DslEntity entity = find(entities, "Formatter");
final DslDefinitionBody definitionBody = new DslDefinitionBodyRule(entity).parse("{ args : \"UPPER\" }", 0).getValue();
Assert.assertEquals(1, definitionBody.getPropertyEntries().size());
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule in project vertigo by KleeGroup.
the class DslDefinitionBodyRuleTest method testError.
@Test
public void testError() {
final List<DslEntity> entities = dslDefinitionRepository.getGrammar().getEntities();
final DslEntity entity = find(entities, "Domain");
final String testValue = "{ dataType : String , formatter : FMT_DEFAULT, constraint : [ CK_CODE_POSTAL ] , maxLengh:\"true\" } ";
try {
new DslDefinitionBodyRule(entity).parse(testValue, 0);
Assert.fail();
} catch (final PegNoMatchFoundException e) {
// System.out.println(e.getFullMessage());
Assert.assertEquals(testValue.indexOf("maxLengh") + "maxLengh".length() - 1, e.getIndex());
}
}
Aggregations