Search in sources :

Example 6 with XmlNormalizerBuilderOperation

use of org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation in project whole by wholeplatform.

the class XsiModelTemplateTest method testXsdModelTemplate.

@Test
public void testXsdModelTemplate() throws Exception {
    String pacs002FileName = "pacs.002.001.02S2.xsd";
    IEntity xsdPacs002 = loadXMLSchema(pacs002FileName);
    CommonsEntityFactory.instance.createRootFragment(xsdPacs002.wGetAdapter(CommonsEntityDescriptorEnum.Any));
    IEntity xmlPacs002 = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(pacs002FileName)));
    CommonsEntityFactory.instance.createRootFragment(xmlPacs002.wGetAdapter(CommonsEntityDescriptorEnum.Any));
    ModelBuilderOperation mop = new ModelBuilderOperation();
    XmlNormalizerBuilderOperation xnbo = new XmlNormalizerBuilderOperation(mop);
    XsdModelTemplate xsdModelTemplate = new XsdModelTemplate(xsdPacs002);
    xsdModelTemplate.apply(xnbo);
    IEntity xmlModelFromXsdPacs002 = mop.wGetResult();
    Assert.assertTrue(OrderedMatcher.match(xmlModelFromXsdPacs002, xmlPacs002, comparatorsMap));
    String credTrfFileName = "SCTCcfBlkCredTrf.xsd";
    IEntity xsdCredTrf = loadXMLSchema(credTrfFileName);
    CommonsEntityFactory.instance.createRootFragment(xsdCredTrf.wGetAdapter(CommonsEntityDescriptorEnum.Any));
    IEntity xmlCredTrf = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(credTrfFileName)));
    CommonsEntityFactory.instance.createRootFragment(xmlCredTrf.wGetAdapter(CommonsEntityDescriptorEnum.Any));
    mop = new ModelBuilderOperation();
    xnbo = new XmlNormalizerBuilderOperation(mop);
    xsdModelTemplate = new XsdModelTemplate(xsdCredTrf);
    xsdModelTemplate.apply(xnbo);
    IEntity xmlModelFromXsdCredTrf = mop.wGetResult();
    Assert.assertTrue(OrderedMatcher.match(xmlModelFromXsdCredTrf, xmlCredTrf, comparatorsMap));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) XmlNormalizerBuilderOperation(org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) Test(org.junit.Test)

Aggregations

ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)6 XmlNormalizerBuilderOperation (org.whole.lang.xml.codebase.XmlNormalizerBuilderOperation)6 Test (org.junit.Test)5 IBindingManager (org.whole.lang.bindings.IBindingManager)4 IEntity (org.whole.lang.model.IEntity)4 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)3 Document (org.whole.lang.xml.model.Document)3 Category (org.junit.experimental.categories.Category)2 IBuilderOperation (org.whole.lang.builders.IBuilderOperation)2 Path (org.whole.lang.queries.model.Path)2 File (java.io.File)1 ModelTemplate (org.whole.lang.templates.ModelTemplate)1 IXmlBuilder (org.whole.lang.xml.builders.IXmlBuilder)1 XmlGenericBuilderAdapter (org.whole.lang.xml.builders.XmlGenericBuilderAdapter)1 Schema (org.whole.lang.xsd.model.Schema)1