use of org.jaffa.persistence.FakeModel in project jaffa-framework by jaffa-projects.
the class TestSupport method setupContext.
/**
* Common initializations
*
* @throws Exception
*/
@BeforeClass
public static void setupContext() throws Exception {
synchronized (lockObject) {
if (appContext != null) {
return;
}
// System.out.println("setupContext()");
appContext = new AnnotationConfigApplicationContext(JaffaRulesConfig.class, TestConfig.class);
assertNotNull(appContext);
Rule label = new Rule();
label.setName("label");
Parameter value = new Parameter();
value.setName("value");
label.addParameter(value);
Parameter condition = new Parameter();
condition.setName("condition");
label.addParameter(condition);
RuleRepository.instance().addRule(label);
// get fake model bean from combined app context
fakeModel = appContext.getBean("fakeModel", FakeModel.class);
assertNotNull(fakeModel);
engine = mock(IPersistenceEngine.class);
IPersistenceEngineFactory persistenceEngineFactory = mock(IPersistenceEngineFactory.class);
when(persistenceEngineFactory.newPersistenceEngine()).thenReturn(engine);
PersistenceEngineFactory.setFactory(persistenceEngineFactory);
}
}
use of org.jaffa.persistence.FakeModel in project jaffa-framework by jaffa-projects.
the class RuleInitializerFactoryTest method testDifferent.
/**
* Hits with different classes should return different instances.
*/
@Test
public void testDifferent() throws JaffaRulesFrameworkException {
Initializer<TestModel> initializer1 = target.getInitializer(new TestModel());
Initializer<FakeModel> initializer2 = target.getInitializer(new FakeModel());
assertNotSame(initializer1, initializer2);
}
use of org.jaffa.persistence.FakeModel in project jaffa-framework by jaffa-projects.
the class RuleValidatorFactoryTest method testCaching.
/**
* Multiple hits to the same class/realm/variation should return the same instance.
*/
@Test
public void testCaching() {
Validator validator1 = target.getValidator(new FakeModel());
Validator validator2 = target.getValidator(new FakeModel());
assertSame(validator1, validator2);
}
Aggregations