use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class XsdModelBuilderTest method testBuilderAPI.
@Category(KnownFailingTests.class)
@Test
public void testBuilderAPI() throws Exception {
Schema xsdFromInputStream = (Schema) XsdPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("datatypes.xsd")));
Document document = (Document) XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("datatypes.xsd")));
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
bm.wDefValue("mergeCDataSect", true);
XsdDeployStrategies.setDeployStrategy(bm, XsdDeployStrategies.ALL);
ModelBuilderOperation mop = new ModelBuilderOperation();
IBuilderOperation xsdBuilderOperation = new XmlSpecific2XsdBuilderAdapterOperation(mop, bm);
XmlNormalizerBuilderOperation normalizerOp = new XmlNormalizerBuilderOperation(xsdBuilderOperation, bm);
ModelTemplate template = new ModelTemplate(document);
template.apply(new XmlGenericBuilderAdapter((IXmlBuilder) normalizerOp.wGetBuilder(XmlLanguageKit.URI)));
Schema xsdFromXmlModel = (Schema) mop.wGetResult();
Assert.assertTrue(Matcher.match(xsdFromInputStream, xsdFromXmlModel));
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class ResourceTemplateTest method getMetadataPattern.
private IEntity getMetadataPattern() {
ModelBuilderOperation op = new ModelBuilderOperation();
IArtifactsBuilder ab = (IArtifactsBuilder) op.wGetBuilder(ArtifactsLanguageKit.URI);
ICommonsBuilder cb = (ICommonsBuilder) op.wGetBuilder(CommonsLanguageKit.URI);
ab.Metadata_();
cb.Resolver();
cb.Resolver();
cb.Resolver();
ab.Attributes_(1);
ab.Attribute(AttributeEnum.readonly);
ab._Attributes();
cb.Resolver();
ab._Metadata();
return op.wGetResult();
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class ResourceTemplateTest method getFilesystemPattern.
private IEntity getFilesystemPattern() {
ModelBuilderOperation op = new ModelBuilderOperation();
IArtifactsBuilder ab = (IArtifactsBuilder) op.wGetBuilder(ArtifactsLanguageKit.URI);
ICommonsBuilder cb = (ICommonsBuilder) op.wGetBuilder(CommonsLanguageKit.URI);
ab.FolderArtifact_();
ab.Name("testfolder");
cb.Resolver();
ab.Artifacts_(3);
ab.FolderArtifact_();
ab.Name("empty.folder");
cb.Resolver();
ab.Artifacts();
ab._FolderArtifact();
ab.FolderArtifact_();
ab.Name("subfolder");
cb.Resolver();
ab.Artifacts_(1);
ab.FileArtifact_();
ab.NameWithExtension_();
ab.Name("test");
ab.Extension("txt");
ab._NameWithExtension();
cb.Resolver();
cb.Resolver();
ab._FileArtifact();
ab._Artifacts();
ab._FolderArtifact();
ab.FileArtifact_();
ab.NameWithExtension_();
ab.Name("test.extensions");
ab.Extension("txt");
ab._NameWithExtension();
cb.Resolver();
cb.Resolver();
ab._FileArtifact();
ab.FileArtifact_();
ab.Name("withoutext");
cb.Resolver();
cb.Resolver();
ab._FileArtifact();
return op.wGetResult();
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class ResourceTemplateTest method testSubtreeArtifacts.
@Test
public void testSubtreeArtifacts() {
File testfolder = new File("data/testfolder");
File testsubfolder = new File("data/testfolder/subfolder");
ResourceTemplate template = new ResourceTemplate(testfolder);
ModelBuilderOperation op = new ModelBuilderOperation();
template.apply(op);
IEntity testFolder = op.wGetResult();
template = new ResourceTemplate(testsubfolder);
op = new ModelBuilderOperation();
template.apply(op);
IEntity testSubFolder = op.wGetResult();
FolderArtifact compareTo = null;
IEntityIterator<FolderArtifact> iterator = IteratorFactory.<FolderArtifact>childMatcherIterator().withPattern(ArtifactsEntityDescriptorEnum.FolderArtifact);
iterator.reset(testFolder.wGet(ArtifactsFeatureDescriptorEnum.artifacts));
while (iterator.hasNext()) {
FolderArtifact folder = iterator.next();
if (folder.getName().wEquals(testSubFolder.wGet(ArtifactsFeatureDescriptorEnum.name))) {
compareTo = folder;
break;
}
}
assertNotNull(compareTo);
assertTrue(OrderedMatcher.match(testSubFolder, compareTo, comparatorsMap));
}
use of org.whole.lang.builders.ModelBuilderOperation in project whole by wholeplatform.
the class ResourceTemplateTest method testReadOnlyArtifact.
@Test
public void testReadOnlyArtifact() throws IOException {
IEntity readOnlyMetadata = getMetadataPattern();
File tempFile = File.createTempFile("whole", null);
tempFile.deleteOnExit();
ResourceTemplate template = new ResourceTemplate(tempFile);
ModelBuilderOperation op = new ModelBuilderOperation();
template.apply(op);
IEntity readWriteArtifact = op.wGetResult();
assertFalse(Matcher.match(readOnlyMetadata, readWriteArtifact));
tempFile.setReadOnly();
template = new ResourceTemplate(tempFile);
op = new ModelBuilderOperation();
template.apply(op);
IEntity readOnlyArtifact = op.wGetResult();
assertFalse(Matcher.match(readOnlyMetadata, readOnlyArtifact));
}
Aggregations