Search in sources :

Example 1 with DslDefinitionBodyRule

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);
}
Also used : DslDefinitionBody(io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionBody) DslEntity(io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity) DslDefinitionBodyRule(io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule) Test(org.junit.Test)

Example 2 with DslDefinitionBodyRule

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());
}
Also used : DslDefinitionBody(io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionBody) DslEntity(io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity) DslDefinitionBodyRule(io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule) Test(org.junit.Test)

Example 3 with DslDefinitionBodyRule

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());
    }
}
Also used : PegNoMatchFoundException(io.vertigo.commons.peg.PegNoMatchFoundException) DslEntity(io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity) DslDefinitionBodyRule(io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule) Test(org.junit.Test)

Aggregations

DslEntity (io.vertigo.dynamo.plugins.environment.dsl.entity.DslEntity)3 DslDefinitionBodyRule (io.vertigo.dynamo.plugins.environment.loaders.kpr.rules.DslDefinitionBodyRule)3 Test (org.junit.Test)3 DslDefinitionBody (io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionBody)2 PegNoMatchFoundException (io.vertigo.commons.peg.PegNoMatchFoundException)1