Search in sources :

Example 1 with Parameter

use of org.jaffa.rules.rulemeta.Parameter 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);
    }
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) IPersistenceEngineFactory(org.jaffa.persistence.engines.IPersistenceEngineFactory) JaffaRulesConfig(org.jaffa.config.JaffaRulesConfig) Parameter(org.jaffa.rules.rulemeta.Parameter) FakeModel(org.jaffa.persistence.FakeModel) Rule(org.jaffa.rules.rulemeta.Rule) IPersistenceEngine(org.jaffa.persistence.engines.IPersistenceEngine) BeforeClass(org.junit.BeforeClass)

Aggregations

JaffaRulesConfig (org.jaffa.config.JaffaRulesConfig)1 FakeModel (org.jaffa.persistence.FakeModel)1 IPersistenceEngine (org.jaffa.persistence.engines.IPersistenceEngine)1 IPersistenceEngineFactory (org.jaffa.persistence.engines.IPersistenceEngineFactory)1 Parameter (org.jaffa.rules.rulemeta.Parameter)1 Rule (org.jaffa.rules.rulemeta.Rule)1 BeforeClass (org.junit.BeforeClass)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1