All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.n2oapp.framework.config.test.SourceCompileTestBase Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
package net.n2oapp.framework.config.test;

import net.n2oapp.criteria.dataset.DataSet;
import net.n2oapp.framework.api.metadata.Compiled;
import net.n2oapp.framework.api.metadata.compile.CompileContext;
import net.n2oapp.framework.api.metadata.pipeline.*;
import net.n2oapp.framework.config.compile.pipeline.N2oPipelineSupport;
import net.n2oapp.framework.config.selective.CompileInfo;

import java.util.Map;
import java.util.stream.Stream;

/**
 * Базовый класс для тестирования сборщиков метаданных {@link net.n2oapp.framework.api.metadata.compile.SourceCompiler}
 */
public abstract class SourceCompileTestBase extends N2oTestBase {

    public ReadTerminalPipeline> read(String... uri) {
        if (uri != null)
            Stream.of(uri).forEach(u -> builder.sources(new CompileInfo(u)));
        return builder.read();
    }

    public ReadCompileTerminalPipeline compile(String... uri) {
        if (uri != null)
            Stream.of(uri).forEach(u -> builder.sources(new CompileInfo(u)));
        return builder.read().compile();
    }

    public ReadCompileBindTerminalPipeline bind(String... uri) {
        if (uri != null)
            Stream.of(uri).forEach(u -> builder.sources(new CompileInfo(u)));
        return builder.read().compile().bind();
    }

    public CompileTerminalPipeline compile() {
        return N2oPipelineSupport.compilePipeline(builder.getEnvironment()).compile();
    }

    public BindTerminalPipeline bind() {
        return N2oPipelineSupport.bindPipeline(builder.getEnvironment()).bind();
    }

    public  CompileContext route(String url, Class compiledClass) {
        return this.route(url, compiledClass, null);
    }

    public  CompileContext route(String url, Class compiledClass, Map params) {
        return builder.route(url, compiledClass, params);
    }

    public  D routeAndGet(String url, Class compiledClass) {
        CompileContext context = builder.route(url, compiledClass, null);
        return read().compile().bind().get(context, context.getParams(url, null));
    }

    public  D routeAndGet(String url, Class compiledClass, Map params) {
        CompileContext context = builder.route(url, compiledClass, params);
        DataSet data = context.getParams(url, params);
        return read().compile().bind().get(context, data);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy