Search in sources :

Example 1 with ResourceTemplate

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));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) ResourceTemplate(org.whole.lang.artifacts.templates.ResourceTemplate) FolderArtifact(org.whole.lang.artifacts.model.FolderArtifact) File(java.io.File) Test(org.junit.Test)

Example 2 with ResourceTemplate

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));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) ResourceTemplate(org.whole.lang.artifacts.templates.ResourceTemplate) File(java.io.File) Test(org.junit.Test)

Example 3 with ResourceTemplate

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));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) ArtifactsEntityFactory(org.whole.lang.artifacts.factories.ArtifactsEntityFactory) IEntity(org.whole.lang.model.IEntity) ResourceTemplate(org.whole.lang.artifacts.templates.ResourceTemplate) File(java.io.File) Test(org.junit.Test)

Example 4 with ResourceTemplate

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));
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) IEntity(org.whole.lang.model.IEntity) ResourceTemplate(org.whole.lang.artifacts.templates.ResourceTemplate) File(java.io.File) Test(org.junit.Test)

Example 5 with ResourceTemplate

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();
}
Also used : ModelBuilderOperation(org.whole.lang.builders.ModelBuilderOperation) ResourceTemplate(org.whole.lang.artifacts.templates.ResourceTemplate)

Aggregations

ResourceTemplate (org.whole.lang.artifacts.templates.ResourceTemplate)5 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)5 File (java.io.File)4 Test (org.junit.Test)4 IEntity (org.whole.lang.model.IEntity)4 ArtifactsEntityFactory (org.whole.lang.artifacts.factories.ArtifactsEntityFactory)1 FolderArtifact (org.whole.lang.artifacts.model.FolderArtifact)1