Search in sources :

Example 11 with ReaderFactoryByMap

use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.

the class RouterTest method setUp.

@Before
public void setUp() {
    N2oEnvironment env = new N2oEnvironment();
    env.setSystemProperties(new SimplePropertyResolver(new Properties()));
    env.setNamespacePersisterFactory(new PersisterFactoryByMap());
    env.setNamespaceReaderFactory(new ReaderFactoryByMap());
    builder = new N2oApplicationBuilder(env).packs(new N2oOperationsPack());
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) N2oOperationsPack(net.n2oapp.framework.config.metadata.pack.N2oOperationsPack) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) Properties(java.util.Properties) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver) Before(org.junit.Before)

Example 12 with ReaderFactoryByMap

use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.

the class N2oApplicationBuilderTest method test.

@Test
@Ignore
public void test() {
    ReadCompileBindTerminalPipeline pipeline = new N2oApplicationBuilder().scanners(new MockInfoScanner()).loaders(new XmlMetadataLoader(new ReaderFactoryByMap().register(new SimplePageElementIOv3()))).compilers(new StandardPageCompiler()).sources(new XmlInfo("test", N2oPage.class, "classpath:", "net/n2oapp/framework/config/test.page.xml")).routes(new RouteInfo("/test", new PageContext("test"))).propertySources("application-test.properties").scan().read().compile().bind();
    new N2oApplicationBuilder().compile().copy().cache().bind();
    // new N2oApplicationBuilder().read().cache().validate().persist().set(null);
    // new N2oApplicationBuilder().read().merge().get()
    Page page = pipeline.get(new PageContext("test"), new DataSet());
}
Also used : N2oPage(net.n2oapp.framework.api.metadata.global.view.page.N2oPage) XmlMetadataLoader(net.n2oapp.framework.config.reader.XmlMetadataLoader) DataSet(net.n2oapp.criteria.dataset.DataSet) MockInfoScanner(net.n2oapp.framework.config.register.scanner.MockInfoScanner) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) N2oPage(net.n2oapp.framework.api.metadata.global.view.page.N2oPage) Page(net.n2oapp.framework.api.metadata.meta.page.Page) ReadCompileBindTerminalPipeline(net.n2oapp.framework.api.metadata.pipeline.ReadCompileBindTerminalPipeline) PageContext(net.n2oapp.framework.config.metadata.compile.context.PageContext) SimplePageElementIOv3(net.n2oapp.framework.config.io.page.v3.SimplePageElementIOv3) StandardPageCompiler(net.n2oapp.framework.config.metadata.compile.page.StandardPageCompiler) XmlInfo(net.n2oapp.framework.config.register.XmlInfo) RouteInfo(net.n2oapp.framework.api.register.route.RouteInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with ReaderFactoryByMap

use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.

the class IOProcessorTest method testChildren.

@Test
public void testChildren() throws Exception {
    ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
    readerFactory.register(new BodyNamespaceEntityIO());
    IOProcessor p = new IOProcessorImpl(readerFactory);
    Element in1 = dom("net/n2oapp/framework/config/io/ioprocessor12.xml");
    Element in2 = dom("net/n2oapp/framework/config/io/ioprocessor15.xml");
    ChildrenEntityList childrenEntityList1 = new ChildrenEntityList();
    ChildrenEntityList childrenEntityList2 = new ChildrenEntityList();
    p.children(in1, "children", "el1", childrenEntityList1::getChildEntities, childrenEntityList1::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
    p.children(in2, null, "el1", childrenEntityList2::getChildEntities, childrenEntityList2::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
    assertThat(childrenEntityList1.getChildEntities().length, equalTo(3));
    assertThat(childrenEntityList1.getChildEntities()[0].getAtt(), equalTo("test1"));
    assertThat(childrenEntityList1.getChildEntities()[1].getAtt(), equalTo("test2"));
    assertThat(childrenEntityList1.getChildEntities()[2].getAtt(), equalTo("test3"));
    assertThat(childrenEntityList2.getChildEntities().length, equalTo(3));
    assertThat(childrenEntityList2.getChildEntities()[0].getAtt(), equalTo("test1"));
    assertThat(childrenEntityList2.getChildEntities()[1].getAtt(), equalTo("test2"));
    assertThat(childrenEntityList2.getChildEntities()[2].getAtt(), equalTo("test3"));
    PersisterFactoryByMap persisterFactory = new PersisterFactoryByMap();
    persisterFactory.register(new BodyNamespaceEntityIO());
    p = new IOProcessorImpl(persisterFactory);
    Element out1 = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
    Element out2 = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
    p.children(out1, "children", "el1", childrenEntityList1::getChildEntities, childrenEntityList1::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
    p.children(out2, null, "el1", childrenEntityList2::getChildEntities, childrenEntityList2::setChildEntities, IOProcessorTest.ChildEntity::new, this::children);
    assertThat(in1, isSimilarTo(out1));
    assertThat(in2, isSimilarTo(out2));
}
Also used : PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) Test(org.junit.Test)

Example 14 with ReaderFactoryByMap

use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.

the class IOProcessorTest method testChildrenToMap.

@Test
public void testChildrenToMap() throws Exception {
    ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
    IOProcessor pR = new IOProcessorImpl(readerFactory);
    readerFactory.register(new BodyNamespaceEntityIO());
    Element in = dom("net/n2oapp/framework/config/io/ioprocessor7.xml");
    MapNamespaceEntity map = new MapNamespaceEntity();
    pR.childrenToMap(in, "children", "el2", "attr", null, map::getEntityMap, map::setEntityMap);
    assertThat(map.getEntityMap().get("1"), equalTo(1));
    assertThat(map.getEntityMap().get("test2"), equalTo("test2"));
    PersisterFactoryByMap persisterFactory = new PersisterFactoryByMap();
    persisterFactory.register(new BodyNamespaceEntityIO());
    IOProcessor pW = new IOProcessorImpl(persisterFactory);
    Element out = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
    pW.childrenToMap(out, "children", "el2", "attr", null, map::getEntityMap, map::setEntityMap);
    assertThat(in, isSimilarTo(out));
    map.entityMap.clear();
    in = dom("net/n2oapp/framework/config/io/ioprocessor24.xml");
    pR.childrenToMap(in, "children", "el", map::getEntityMap, map::setEntityMap);
    assertThat(map.getEntityMap().get("attr"), equalTo(1));
    assertThat(map.getEntityMap().get("attr1"), equalTo("test1"));
    out = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
    pW.childrenToMap(out, "children", "el", map::getEntityMap, map::setEntityMap);
    assertThat(in, isSimilarTo(out));
}
Also used : PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) Test(org.junit.Test)

Example 15 with ReaderFactoryByMap

use of net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap in project n2o-framework by i-novus-llc.

the class IOProcessorTest method testElement.

@Test
public void testElement() throws Exception {
    ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
    readerFactory.register(new BodyNamespaceEntityIO());
    IOProcessor p = new IOProcessorImpl(readerFactory);
    Element in = dom("net/n2oapp/framework/config/io/ioprocessor17.xml");
    BaseEntity baseEntity = new BaseEntity();
    p.element(in, "attr", baseEntity::getAttr, baseEntity::setAttr);
    assertThat(baseEntity.getAttr(), equalTo("test"));
    PersisterFactoryByMap persisterFactory = new PersisterFactoryByMap();
    persisterFactory.register(new BodyNamespaceEntityIO());
    p = new IOProcessorImpl(persisterFactory);
    Element out = new Element("test", Namespace.getNamespace("http://example.com/n2o/ext-1.0"));
    p.element(out, "attr", baseEntity::getAttr, baseEntity::setAttr);
    assertThat(in, isSimilarTo(out));
}
Also used : PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) Test(org.junit.Test)

Aggregations

ReaderFactoryByMap (net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap)16 PersisterFactoryByMap (net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap)13 Test (org.junit.Test)11 N2oApplicationBuilder (net.n2oapp.framework.config.N2oApplicationBuilder)5 N2oEnvironment (net.n2oapp.framework.config.compile.pipeline.N2oEnvironment)5 SimplePropertyResolver (net.n2oapp.framework.config.test.SimplePropertyResolver)5 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)5 ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)5 OverrideProperties (net.n2oapp.properties.OverrideProperties)4 Before (org.junit.Before)4 Properties (java.util.Properties)2 SimplePageElementIOv3 (net.n2oapp.framework.config.io.page.v3.SimplePageElementIOv3)2 XmlMetadataLoader (net.n2oapp.framework.config.reader.XmlMetadataLoader)2 XmlInfo (net.n2oapp.framework.config.register.XmlInfo)2 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 DataSet (net.n2oapp.criteria.dataset.DataSet)1 N2oException (net.n2oapp.framework.api.exception.N2oException)1 SourceMetadata (net.n2oapp.framework.api.metadata.SourceMetadata)1 N2oPage (net.n2oapp.framework.api.metadata.global.view.page.N2oPage)1