use of org.jaffa.rules.realm.Realm in project jaffa-framework by jaffa-projects.
the class RealmRepositoryTest method testAddRealm.
/**
* Registering a Rule should behave as though it were loaded from an XML element.
*/
@Test
public void testAddRealm() {
Realm realm = new Realm("x");
realm.setSource("s");
RealmRepository target = RealmRepository.instance();
target.addRealm(realm);
List<Realm> actual = target.getRealmsBySource("s");
assertEquals(1, actual.size());
assertSame(realm, actual.get(0));
}
use of org.jaffa.rules.realm.Realm in project jaffa-framework by jaffa-projects.
the class RealmTest method testRealmConfig.
/**
* Test code configuration.
*/
// This is flakey when run with other repository tests.
// @Test
public void testRealmConfig() {
Realm target = new Realm("oz").regex(TestModel.class.getName()).inheritanceRulesToInclude("a,b").inheritanceRulesToExclude("x,y").register();
assertEquals("oz", RealmRepository.instance().find(TestModel.class.getName()));
List<String> regexes = target.getClassRegexes();
assertNotNull(regexes);
assertEquals(1, regexes.size());
assertEquals(TestModel.class.getName(), regexes.get(0));
assertEquals("a", target.getInheritanceRulesToInclude().get(0));
assertEquals("b", target.getInheritanceRulesToInclude().get(1));
assertEquals("x", target.getInheritanceRulesToExclude().get(0));
assertEquals("y", target.getInheritanceRulesToExclude().get(1));
}
use of org.jaffa.rules.realm.Realm in project jaffa-framework by jaffa-projects.
the class PersistentConfigValidatorTest method setup.
/**
* Common setup
*
* @throws Exception
*/
@Before
public void setup() throws Exception {
// create app context, do not need to include PersistentContext directly
AnnotationConfigApplicationContext appContext = new AnnotationConfigApplicationContext(JaffaRulesConfig.class, TestModelPersistentConfig.class);
assertNotNull(appContext);
new StaticContext().setApplicationContext(appContext);
// get validator factory bean from combined app context
ValidatorFactory target = appContext.getBean(ValidatorFactory.class);
assertNotNull(target);
Realm realm = new Realm("realm");
realm.setSource("Test");
realm.regex(TestModelPersistent.class.getName());
realm.register();
ClassMetaData classMetaData = new ClassMetaData();
classMetaData.setName(TestModelPersistent.class.getName());
classMetaData.setVariation("DEF");
classMetaData.setExecutionRealm(realm.getName());
classMetaData.register();
}
use of org.jaffa.rules.realm.Realm in project jaffa-framework by jaffa-projects.
the class TestConfig method realm.
private Realm realm(String name) {
Realm realm = new Realm(name);
realm.setSource("RealmConfig");
return realm;
}
use of org.jaffa.rules.realm.Realm 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();
}
Aggregations