Search in sources :

Example 6 with ReaderFactoryByMap

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

the class IOProcessorTest method testChildrenToMapString.

@Test
public void testChildrenToMapString() throws Exception {
    ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
    IOProcessor p = new IOProcessorImpl(readerFactory);
    readerFactory.register(new BodyNamespaceEntityIO());
    Element in = dom("net/n2oapp/framework/config/io/ioprocessor7.xml");
    MapStringNamespaceEntity map = new MapStringNamespaceEntity();
    p.childrenToStringMap(in, "children", "el2", "attr", null, map::getEntityStringMap, map::setEntityStringMap);
    assertThat(map.getEntityStringMap().get("1"), equalTo("1"));
    assertThat(map.getEntityStringMap().get("test2"), equalTo("test2"));
    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.childrenToStringMap(out, "children", "el2", "attr", null, map::getEntityStringMap, map::setEntityStringMap);
    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 7 with ReaderFactoryByMap

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

the class N2oTestBase method setUp.

public void setUp() throws Exception {
    N2oEnvironment environment = new N2oEnvironment();
    environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
    environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.addBasenames("n2o_api_messages", "n2o_api_messages", "n2o_config_messages", "test_messages", "messages");
    messageSource.setDefaultEncoding("UTF-8");
    Locale locale = new Locale("ru");
    LocaleContextHolder.setLocale(locale);
    environment.setMessageSource(new MessageSourceAccessor(messageSource));
    OverrideProperties n2oProperties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
    OverrideProperties appProperties = PropertiesReader.getPropertiesFromClasspath("application.properties");
    appProperties.setBaseProperties(n2oProperties);
    environment.setSystemProperties(new SimplePropertyResolver(appProperties));
    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
Also used : Locale(java.util.Locale) N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) OverrideProperties(net.n2oapp.properties.OverrideProperties)

Example 8 with ReaderFactoryByMap

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

the class IOProcessorTest method testChild.

@Test
public void testChild() throws Exception {
    ReaderFactoryByMap readerFactory = new ReaderFactoryByMap();
    readerFactory.register(new BodyNamespaceEntityIO());
    IOProcessor p = new IOProcessorImpl(readerFactory);
    Element in1 = dom("net/n2oapp/framework/config/io/ioprocessor13.xml");
    Element in2 = dom("net/n2oapp/framework/config/io/ioprocessor14.xml");
    ChildEntity childrenEntity1 = new ChildEntity();
    ChildEntity childrenEntity2 = new ChildEntity();
    p.child(in1, "children", "el1", childrenEntity1::getChild, childrenEntity1::setChild, IOProcessorTest.ChildEntity::new, this::children);
    p.child(in2, null, "el1", childrenEntity2::getChild, childrenEntity2::setChild, IOProcessorTest.ChildEntity::new, this::children);
    assertThat(childrenEntity1.getChild().getAtt(), equalTo("test1"));
    assertThat(childrenEntity2.getChild().getAtt(), equalTo("test1"));
    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.child(out1, "children", "el1", childrenEntity1::getChild, childrenEntity1::setChild, IOProcessorTest.ChildEntity::new, this::children);
    p.child(out2, null, "el1", childrenEntity2::getChild, childrenEntity2::setChild, 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 9 with ReaderFactoryByMap

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

the class CopyValuesControllerTest method setUp.

@Before
public void setUp() {
    N2oEnvironment environment = new N2oEnvironment();
    environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
    environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("n2o_messages", "messages");
    messageSource.setDefaultEncoding("UTF-8");
    environment.setMessageSource(new MessageSourceAccessor(messageSource));
    OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
    properties.put("n2o.engine.mapper", "spel");
    environment.setSystemProperties(new SimplePropertyResolver(properties));
    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) OverrideProperties(net.n2oapp.properties.OverrideProperties) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver) Before(org.junit.Before)

Example 10 with ReaderFactoryByMap

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

the class DefaultValuesControllerTest method setUp.

@Before
public void setUp() {
    N2oEnvironment environment = new N2oEnvironment();
    environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
    environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("n2o_messages", "messages");
    messageSource.setDefaultEncoding("UTF-8");
    environment.setMessageSource(new MessageSourceAccessor(messageSource));
    OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
    properties.put("n2o.engine.mapper", "spel");
    environment.setSystemProperties(new SimplePropertyResolver(properties));
    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
Also used : N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) PersisterFactoryByMap(net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap) MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) N2oApplicationBuilder(net.n2oapp.framework.config.N2oApplicationBuilder) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ReaderFactoryByMap(net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap) OverrideProperties(net.n2oapp.properties.OverrideProperties) SimplePropertyResolver(net.n2oapp.framework.config.test.SimplePropertyResolver) Before(org.junit.Before)

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