use of org.whole.lang.artifacts.templates.ResourceTemplate 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.artifacts.templates.ResourceTemplate 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));
}
use of org.whole.lang.artifacts.templates.ResourceTemplate in project whole by wholeplatform.
the class ResourceArtifactsGeneratorTest method test2CompareArtifacts.
@Test
public void test2CompareArtifacts() {
ArtifactsEntityFactory aef = ArtifactsEntityFactory.instance;
File genFolder = new File("data/gen");
ResourceTemplate resourceTemplate = new ResourceTemplate(genFolder);
ModelBuilderOperation mop = new ModelBuilderOperation();
resourceTemplate.apply(mop);
IEntity artifactsRevEng = mop.wGetResult();
IEntity artifactsSubTree = Matcher.find(aef.createFolderArtifact(aef.createName("gen"), CommonsEntityAdapterFactory.createVariable(ArtifactsEntityDescriptorEnum.Metadata, "metadata"), CommonsEntityAdapterFactory.createVariable(ArtifactsEntityDescriptorEnum.Artifacts, "artifacts")), artifacts, false);
assertNotNull(artifactsSubTree);
assertTrue(OrderedMatcher.match(artifactsRevEng, artifactsSubTree, comparatorsMap));
}
use of org.whole.lang.artifacts.templates.ResourceTemplate in project whole by wholeplatform.
the class ResourceTemplateTest method testReadArtifacts.
@Test
public void testReadArtifacts() {
File testfolder = new File("data/testfolder");
ResourceTemplate template = new ResourceTemplate(testfolder);
ModelBuilderOperation op = new ModelBuilderOperation();
template.apply(op);
IEntity artifacts = getFilesystemPattern();
IEntity artifactsFromFilesystem = op.wGetResult();
assertTrue(OrderedMatcher.match(artifacts, artifactsFromFilesystem, comparatorsMap));
}
use of org.whole.lang.artifacts.templates.ResourceTemplate in project whole by wholeplatform.
the class ResourceArtifactsOperations method toArtifactsModel.
public IEntity toArtifactsModel(File resource) {
ModelBuilderOperation mbo = new ModelBuilderOperation();
ResourceTemplate resourceTemplate = new ResourceTemplate(resource);
resourceTemplate.apply(mbo);
return mbo.wGetResult();
}
Aggregations