Search in sources :

Example 1 with SpringDataProcessingStack

use of net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack in project n2o-framework by i-novus-llc.

the class DataControllerTest method testOperation.

private SetDataResponse testOperation(String path, ReadCompileTerminalPipeline<ReadCompileBindTerminalPipeline> pipeline, Map<String, String[]> params, DataSet body) {
    N2oInvocationFactory invocationFactory = Mockito.mock(N2oInvocationFactory.class);
    TestDataProviderEngine testDataProviderEngine = new TestDataProviderEngine();
    testDataProviderEngine.setResourceLoader(new DefaultResourceLoader());
    Mockito.when(invocationFactory.produce(Mockito.any(Class.class))).thenReturn(testDataProviderEngine);
    N2oInvocationProcessor invocationProcessor = new N2oInvocationProcessor(invocationFactory);
    invocationProcessor.setEnvironment(builder.getEnvironment());
    N2oValidationModule validationModule = new N2oValidationModule(new ValidationProcessor(invocationProcessor));
    Map<String, DataProcessing> moduleMap = new HashMap<>();
    moduleMap.put("validationModule", validationModule);
    N2oOperationProcessor operationProcessor = new N2oOperationProcessor(invocationProcessor, new N2oOperationExceptionHandler());
    ApplicationContext context = Mockito.mock(ApplicationContext.class);
    Mockito.when(context.getBeansOfType(DataProcessing.class)).thenReturn(moduleMap);
    DataProcessingStack dataProcessingStack = new SpringDataProcessingStack();
    ((SpringDataProcessingStack) dataProcessingStack).setApplicationContext(context);
    N2oRouter router = new N2oRouter(builder.getEnvironment(), pipeline);
    ContextEngine contextEngine = Mockito.mock(ContextEngine.class);
    Map<String, Object> map = new HashMap<>();
    AlertMessageBuilder messageBuilder = new AlertMessageBuilder(builder.getEnvironment().getMessageSource(), null);
    OperationController operationController = new OperationController(dataProcessingStack, operationProcessor, messageBuilder, builder.getEnvironment());
    map.put("operationController", operationController);
    N2oControllerFactory factory = new N2oControllerFactory(map);
    factory.setEnvironment(builder.getEnvironment());
    DataController controller = new DataController(factory, builder.getEnvironment(), router);
    controller.setMessageBuilder(messageBuilder);
    return controller.setData(path, params, null, body, new UserContext(contextEngine));
}
Also used : N2oInvocationFactory(net.n2oapp.framework.engine.data.N2oInvocationFactory) HashMap(java.util.HashMap) N2oOperationProcessor(net.n2oapp.framework.engine.data.N2oOperationProcessor) ContextEngine(net.n2oapp.framework.api.context.ContextEngine) DataProcessing(net.n2oapp.framework.api.processing.DataProcessing) ApplicationContext(org.springframework.context.ApplicationContext) N2oValidationModule(net.n2oapp.framework.engine.validation.N2oValidationModule) ValidationProcessor(net.n2oapp.framework.engine.validation.engine.ValidationProcessor) N2oOperationExceptionHandler(net.n2oapp.framework.engine.data.N2oOperationExceptionHandler) N2oRouter(net.n2oapp.framework.config.register.route.N2oRouter) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) OperationController(net.n2oapp.framework.ui.controller.action.OperationController) SpringDataProcessingStack(net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack) DataProcessingStack(net.n2oapp.framework.engine.modules.stack.DataProcessingStack) AlertMessageBuilder(net.n2oapp.framework.api.ui.AlertMessageBuilder) UserContext(net.n2oapp.framework.api.user.UserContext) TestDataProviderEngine(net.n2oapp.framework.engine.data.json.TestDataProviderEngine) N2oInvocationProcessor(net.n2oapp.framework.engine.data.N2oInvocationProcessor) SpringDataProcessingStack(net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack)

Example 2 with SpringDataProcessingStack

use of net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack in project n2o-framework by i-novus-llc.

the class N2oEngineConfiguration method dataProcessingStack.

@Bean
@ConditionalOnMissingBean
public DataProcessingStack dataProcessingStack(ApplicationContext context) {
    SpringDataProcessingStack dataProcessingStack = new SpringDataProcessingStack();
    dataProcessingStack.setApplicationContext(context);
    return dataProcessingStack;
}
Also used : SpringDataProcessingStack(net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

SpringDataProcessingStack (net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack)2 HashMap (java.util.HashMap)1 ContextEngine (net.n2oapp.framework.api.context.ContextEngine)1 DataProcessing (net.n2oapp.framework.api.processing.DataProcessing)1 AlertMessageBuilder (net.n2oapp.framework.api.ui.AlertMessageBuilder)1 UserContext (net.n2oapp.framework.api.user.UserContext)1 N2oRouter (net.n2oapp.framework.config.register.route.N2oRouter)1 N2oInvocationFactory (net.n2oapp.framework.engine.data.N2oInvocationFactory)1 N2oInvocationProcessor (net.n2oapp.framework.engine.data.N2oInvocationProcessor)1 N2oOperationExceptionHandler (net.n2oapp.framework.engine.data.N2oOperationExceptionHandler)1 N2oOperationProcessor (net.n2oapp.framework.engine.data.N2oOperationProcessor)1 TestDataProviderEngine (net.n2oapp.framework.engine.data.json.TestDataProviderEngine)1 DataProcessingStack (net.n2oapp.framework.engine.modules.stack.DataProcessingStack)1 N2oValidationModule (net.n2oapp.framework.engine.validation.N2oValidationModule)1 ValidationProcessor (net.n2oapp.framework.engine.validation.engine.ValidationProcessor)1 OperationController (net.n2oapp.framework.ui.controller.action.OperationController)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)1