use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionEntry in project vertigo by KleeGroup.
the class DslDefinitionEntryRuleTest method test2.
@Test
public void test2() throws PegNoMatchFoundException {
final String text = "myLastProperty : [ ],";
final PegResult<DslDefinitionEntry> cursor = MAIN.parse(text, 0);
final DslDefinitionEntry xDefinitionEntry = cursor.getValue();
Assert.assertEquals("myLastProperty", xDefinitionEntry.getFieldName());
Assert.assertEquals(0, xDefinitionEntry.getDefinitionNames().size());
Assert.assertEquals(text.length(), cursor.getIndex());
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionEntry in project vertigo by KleeGroup.
the class DslDefinitionEntryRuleTest method test1.
@Test
public void test1() throws PegNoMatchFoundException {
final String text = "myFirstProperty : [BLEU, VerT, ROUGE, T_REX ], non reconnu";
final PegResult<DslDefinitionEntry> cursor = MAIN.parse(text, 0);
final DslDefinitionEntry xDefinitionEntry = cursor.getValue();
Assert.assertEquals("myFirstProperty", xDefinitionEntry.getFieldName());
Assert.assertEquals(4, xDefinitionEntry.getDefinitionNames().size());
Assert.assertTrue(xDefinitionEntry.getDefinitionNames().contains("VerT"));
Assert.assertEquals(text.length() - " non reconnu".length(), cursor.getIndex());
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionEntry in project vertigo by KleeGroup.
the class DslDefinitionEntryRuleTest method test4.
@Test
public void test4() throws PegNoMatchFoundException {
final String text = "myFirstProperty : BLEU,";
final PegResult<DslDefinitionEntry> cursor = MAIN.parse(text, 0);
final DslDefinitionEntry xDefinitionEntry = cursor.getValue();
Assert.assertEquals("myFirstProperty", xDefinitionEntry.getFieldName());
Assert.assertEquals(1, xDefinitionEntry.getDefinitionNames().size());
Assert.assertTrue(xDefinitionEntry.getDefinitionNames().contains("BLEU"));
Assert.assertEquals(text.length(), cursor.getIndex());
}
use of io.vertigo.dynamo.plugins.environment.loaders.kpr.definition.DslDefinitionEntry in project vertigo by KleeGroup.
the class DslDefinitionEntryRule method handle.
@Override
protected DslDefinitionEntry handle(final List<Object> parsing) {
final String fieldName = (String) ((PegChoice) parsing.get(0)).getValue();
final List<String> definitionKeys;
final PegChoice definitionChoice = (PegChoice) parsing.get(4);
switch(definitionChoice.getChoiceIndex()) {
case 1:
// Déclaration d'une liste de définitions identifiée par leurs clés
definitionKeys = (List<String>) definitionChoice.getValue();
break;
case 0:
// Déclaration d'une définition identifiée par sa clé
final String value = (String) definitionChoice.getValue();
definitionKeys = java.util.Collections.singletonList(value);
break;
default:
throw new IllegalStateException();
}
return new DslDefinitionEntry(fieldName, definitionKeys);
}
Aggregations