Search in sources :

Example 26 with RepositoryFileReference

use of org.eclipse.winery.common.RepositoryFileReference in project winery by eclipse.

the class BackendUtilsTest method repositoryFileReferenceWithSubdirectoryCorrectlyCreated.

@Test
public void repositoryFileReferenceWithSubdirectoryCorrectlyCreated() {
    ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId("http://www.example.org", "at", false);
    ArtifactTemplateSourceDirectoryId artifactTemplateSourceDirectoryId = new ArtifactTemplateSourceDirectoryId(artifactTemplateId);
    final Path subDirectories = Paths.get("d1", "d2");
    final RepositoryFileReference repositoryFileReference = BackendUtils.getRepositoryFileReference(Paths.get("main"), Paths.get("main", "d1", "d2", "file.txt"), artifactTemplateSourceDirectoryId);
    Assert.assertEquals(artifactTemplateSourceDirectoryId, repositoryFileReference.getParent());
    Assert.assertEquals(Optional.of(subDirectories), repositoryFileReference.getSubDirectory());
    Assert.assertEquals("file.txt", repositoryFileReference.getFileName());
}
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 27 with RepositoryFileReference

use of org.eclipse.winery.common.RepositoryFileReference in project winery by eclipse.

the class FilebasedRepositoryTest method allFilesCorrectlyImported.

@Test
public void allFilesCorrectlyImported() throws Exception {
    this.setRevisionTo("5b7f106ab79a9ba137ece9167a79753dfc64ac84");
    ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId("http://www.example.org", "at", false);
    ArtifactTemplateSourceDirectoryId artifactTemplateSourceDirectoryId = new ArtifactTemplateSourceDirectoryId(artifactTemplateId);
    final Path subDirectories = Paths.get("dir1", "dir2", "dir3");
    Path workingDir = Files.createTempDirectory("winery");
    final Path subDir = workingDir.resolve(subDirectories);
    Files.createDirectories(subDir);
    Path tempFile = subDir.resolve("test.txt");
    Files.createFile(tempFile);
    BackendUtils.importDirectory(workingDir, this.repository, artifactTemplateSourceDirectoryId);
    RepositoryFileReference ref = new RepositoryFileReference(artifactTemplateSourceDirectoryId, subDirectories, "test.txt");
    Assert.assertTrue(repository.exists(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 28 with RepositoryFileReference

use of org.eclipse.winery.common.RepositoryFileReference 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 29 with RepositoryFileReference

use of org.eclipse.winery.common.RepositoryFileReference 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 30 with RepositoryFileReference

use of org.eclipse.winery.common.RepositoryFileReference 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)

Aggregations

RepositoryFileReference (org.eclipse.winery.common.RepositoryFileReference)51 IOException (java.io.IOException)15 InputStream (java.io.InputStream)8 ArtifactTemplateId (org.eclipse.winery.common.ids.definitions.ArtifactTemplateId)8 Definitions (org.eclipse.winery.model.tosca.Definitions)8 BufferedInputStream (java.io.BufferedInputStream)6 ArtifactTemplateSourceDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateSourceDirectoryId)6 Test (org.junit.Test)6 Path (java.nio.file.Path)5 JAXBException (javax.xml.bind.JAXBException)5 MediaType (org.apache.tika.mime.MediaType)5 ArtifactTemplateFilesDirectoryId (org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateFilesDirectoryId)5 ZipInputStream (java.util.zip.ZipInputStream)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 QName (javax.xml.namespace.QName)4 XmlId (org.eclipse.winery.common.ids.XmlId)4 GenericImportId (org.eclipse.winery.common.ids.definitions.imports.GenericImportId)4 XSDImportId (org.eclipse.winery.common.ids.definitions.imports.XSDImportId)4 PlanId (org.eclipse.winery.common.ids.elements.PlanId)4 PlansId (org.eclipse.winery.common.ids.elements.PlansId)4