Search in sources :

Example 11 with ArtifactTemplateId

use of org.eclipse.winery.common.ids.definitions.ArtifactTemplateId in project winery by eclipse.

the class FilebasedRepositoryTest method getTypeForTemplateReturnsCorrectTypeForMyTinyTestArtifactTemplate.

@Test
public void getTypeForTemplateReturnsCorrectTypeForMyTinyTestArtifactTemplate() throws Exception {
    this.setRevisionTo("1374c8c13ec64899360511dbe0414223b88d3b01");
    ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId("http://opentosca.org/artifacttemplates", "MyTinyTest", false);
    final TArtifactTemplate artifactTemplate = this.repository.getElement(artifactTemplateId);
    final TEntityType typeForTemplate = this.repository.getTypeForTemplate(artifactTemplate);
    Assert.assertEquals(new QName("http://winery.opentosca.org/test/artifacttypes", "MiniArtifactType"), new QName(typeForTemplate.getTargetNamespace(), typeForTemplate.getName()));
}
Also used : TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TEntityType(org.eclipse.winery.model.tosca.TEntityType) QName(javax.xml.namespace.QName) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) Test(org.junit.Test)

Example 12 with ArtifactTemplateId

use of org.eclipse.winery.common.ids.definitions.ArtifactTemplateId in project winery by eclipse.

the class FilebasedRepositoryTest method getContainedFilesProducedCorrectPath.

@Test
public void getContainedFilesProducedCorrectPath() throws Exception {
    ArtifactTemplateId artifactTemplateWithFilesAndSourcesId = new ArtifactTemplateId("http://plain.winery.opentosca.org/artifacttemplates", "ArtifactTemplateWithFilesAndSources", false);
    DirectoryId fileDir = new ArtifactTemplateFilesDirectoryId(artifactTemplateWithFilesAndSourcesId);
    SortedSet<RepositoryFileReference> files = repository.getContainedFiles(fileDir);
    for (RepositoryFileReference ref : files) {
        Assert.assertFalse("File " + ref.toString() + " contains empty sub directory", ref.getSubDirectory().isPresent() && ref.getSubDirectory().get().toString().equals(""));
    }
}
Also used : ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) DirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.DirectoryId) ArtifactTemplateSourceDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateSourceDirectoryId) ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) Test(org.junit.Test)

Example 13 with ArtifactTemplateId

use of org.eclipse.winery.common.ids.definitions.ArtifactTemplateId in project winery by eclipse.

the class FilebasedRepositoryTest method subDirectoryExpandedCorrectly.

@Test
public void subDirectoryExpandedCorrectly() throws Exception {
    ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId("http://www.example.org", "at", false);
    ArtifactTemplateSourceDirectoryId artifactTemplateSourceDirectoryId = new ArtifactTemplateSourceDirectoryId(artifactTemplateId);
    final Path subDirectories = Paths.get("dir1", "dir2", "dir3");
    RepositoryFileReference ref = new RepositoryFileReference(artifactTemplateSourceDirectoryId, subDirectories, "test.txt");
    final FilebasedRepository repository = (FilebasedRepository) this.repository;
    final Path expected = Paths.get("artifacttemplates", "http%3A%2F%2Fwww.example.org", "at", "source", "dir1", "dir2", "dir3", "test.txt");
    Assert.assertEquals(expected, repository.getRepositoryRoot().relativize(repository.ref2AbsolutePath(ref)));
}
Also used : Path(java.nio.file.Path) RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference) ArtifactTemplateSourceDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateSourceDirectoryId) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) Test(org.junit.Test)

Example 14 with ArtifactTemplateId

use of org.eclipse.winery.common.ids.definitions.ArtifactTemplateId in project winery by eclipse.

the class FilebasedRepositoryTest method containedFilesRecursesIntoSubDirectories.

@Test
public void containedFilesRecursesIntoSubDirectories() throws Exception {
    this.setRevisionTo("5cda0035a773a9c405a70759731be3977f37e3f3");
    ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId("http://winery.opentosca.org/test/artifacttemplates/fruits", "baobab-ArtifactTemplate-Peel", false);
    ArtifactTemplateFilesDirectoryId directoryId = new ArtifactTemplateFilesDirectoryId(artifactTemplateId);
    final SortedSet<RepositoryFileReference> containedFiles = repository.getContainedFiles(directoryId);
    // TODO: real content (relative paths, ...) not checked
    Assert.assertEquals(3, containedFiles.size());
}
Also used : ArtifactTemplateFilesDirectoryId(org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId) RepositoryFileReference(org.eclipse.winery.common.RepositoryFileReference) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) Test(org.junit.Test)

Example 15 with ArtifactTemplateId

use of org.eclipse.winery.common.ids.definitions.ArtifactTemplateId in project winery by eclipse.

the class CsarExporterTest method csarIsValidZipForArtifactTemplateWithFilesAndSources.

@Test
public void csarIsValidZipForArtifactTemplateWithFilesAndSources() throws Exception {
    try (InputStream inputStream = this.createOutputAndInputStream("origin/plain", new ArtifactTemplateId("http://plain.winery.opentosca.org/artifacttemplates", "ArtifactTemplateWithFilesAndSources-ArtifactTypeWithoutProperties", false));
        ZipInputStream zis = new ZipInputStream(inputStream)) {
        ZipEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            String name = entry.getName();
            Assert.assertNotNull(name);
            Assert.assertFalse("name contains backslashes", name.contains("\\"));
        }
    }
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) Test(org.junit.Test)

Aggregations

ArtifactTemplateId (org.eclipse.winery.common.ids.definitions.ArtifactTemplateId)23 QName (javax.xml.namespace.QName)10 Test (org.junit.Test)9 RepositoryFileReference (org.eclipse.winery.common.RepositoryFileReference)8 ArtifactTypeId (org.eclipse.winery.common.ids.definitions.ArtifactTypeId)6 ArtifactTemplateSourceDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateSourceDirectoryId)6 IOException (java.io.IOException)4 Path (java.nio.file.Path)4 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)4 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)4 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 PolicyTemplateId (org.eclipse.winery.common.ids.definitions.PolicyTemplateId)3 ServiceTemplateId (org.eclipse.winery.common.ids.definitions.ServiceTemplateId)3 ArtifactTemplateFilesDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Response (javax.ws.rs.core.Response)2 JAXBException (javax.xml.bind.JAXBException)2 CapabilityTypeId (org.eclipse.winery.common.ids.definitions.CapabilityTypeId)2 NodeTypeId (org.eclipse.winery.common.ids.definitions.NodeTypeId)2