Search in sources :

Example 6 with ClassMetaData

use of org.jaffa.rules.meta.ClassMetaData in project jaffa-framework by jaffa-projects.

the class TestConfig method testModelMeta.

@Bean
public ClassMetaData testModelMeta() {
    ClassMetaData data = classMetaData(TestModel.class);
    data.property("field1").label("[Field1]").mandatory().maxLength("10").minLength("2").caseType("upper").foreignKey(TestModel.class.getName()).genericForeignKey(TestModel.class.getName(), "field1", null, TestValueClass.class.getName()).partialForeignKey(TestModel.class.getName()).primaryKey("field1").candidateKey("field1", true).comment("fifo").pattern(// IP Address Reg Exp;
    "\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b").inList("in list").notInList("not in list").initialize(FieldInitializerTest.FIELD1_INIT_VALUE);
    data.property("field2").label("[Field2]").maxValue("10").minValue("2").initialize(FieldInitializerTest.FIELD2_INIT_VALUE.toString(), "field2");
    data.property("field3").initialize(Integer.toString(FieldInitializerTest.FIELD3_INIT_VALUE), "field3");
    data.setExecutionRealm("business");
    data.setVariation("DEF");
    data.register();
    return data;
}
Also used : ClassMetaData(org.jaffa.rules.meta.ClassMetaData) Bean(org.springframework.context.annotation.Bean)

Example 7 with ClassMetaData

use of org.jaffa.rules.meta.ClassMetaData in project jaffa-framework by jaffa-projects.

the class RuleInitializerFactoryTest method before.

/**
 * Setup common data.
 */
@Before
public void before() {
    VariationContext.setVariation("A");
    Realm realm = new Realm("realm");
    realm.setSource("Test");
    realm.regex(TestModel.class.getName());
    realm.register();
    ClassMetaData data = new ClassMetaData(TestModel.class);
    data.property("field1").initialize(FieldInitializerTest.FIELD1_INIT_VALUE);
    data.property("field2").initialize(FieldInitializerTest.FIELD2_INIT_VALUE.toString());
    data.setExecutionRealm(realm.getName());
    data.setVariation(VariationContext.getVariation());
    data.register();
    new TestConfig().initializeRule();
    target = new RuleInitializerFactory();
}
Also used : TestConfig(org.jaffa.rules.TestConfig) Realm(org.jaffa.rules.realm.Realm) TestModel(org.jaffa.rules.TestModel) ClassMetaData(org.jaffa.rules.meta.ClassMetaData) Before(org.junit.Before)

Aggregations

ClassMetaData (org.jaffa.rules.meta.ClassMetaData)7 RuleMetaData (org.jaffa.rules.meta.RuleMetaData)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 PropertyMetaData (org.jaffa.rules.meta.PropertyMetaData)2 Realm (org.jaffa.rules.realm.Realm)2 Before (org.junit.Before)2 Bean (org.springframework.context.annotation.Bean)2 ArrayList (java.util.ArrayList)1 StaticContext (org.jaffa.beans.factory.config.StaticContext)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 TestConfig (org.jaffa.rules.TestConfig)1 TestModel (org.jaffa.rules.TestModel)1 ValidatorFactory (org.jaffa.rules.fieldvalidators.ValidatorFactory)1 BeansException (org.springframework.beans.BeansException)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1