Search in sources :

Example 6 with ArchiveRoot

use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.

the class EditorTopologyUploadService method processTopologyDir.

public void processTopologyDir(Path archivePath, String workspace) {
    // parse the archive.
    try {
        ParsingResult<ArchiveRoot> parsingResult = toscaArchiveParser.parseDir(archivePath);
        processTopologyParseResult(archivePath, parsingResult, workspace);
    } catch (ParsingException e) {
        // Manage parsing error and dispatch them in the right editor exception
        throw new EditorToscaYamlParsingException("The uploaded file to override the topology yaml is not a valid Tosca Yaml.", toParsingResult(e));
    }
}
Also used : ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) EditorToscaYamlParsingException(org.alien4cloud.tosca.editor.exception.EditorToscaYamlParsingException) ParsingException(alien4cloud.tosca.parser.ParsingException) EditorToscaYamlParsingException(org.alien4cloud.tosca.editor.exception.EditorToscaYamlParsingException)

Example 7 with ArchiveRoot

use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.

the class ArchiveParserTest method parseNormativeTypes.

@Test
public void parseNormativeTypes() throws ParsingException, IOException {
    String localName = "tosca-normative-types";
    repositoryManager.cloneOrCheckout(artifactsDirectory, "https://github.com/alien4cloud/tosca-normative-types.git", "master", localName);
    Path normativeTypesPath = artifactsDirectory.resolve(localName);
    Path normativeTypesZipPath = artifactsDirectory.resolve(localName + ".zip");
    // Update zip
    FileUtil.zip(normativeTypesPath, normativeTypesZipPath);
    ParsingResult<ArchiveRoot> parsingResult = archiveParser.parse(normativeTypesZipPath, AlienConstants.GLOBAL_WORKSPACE_ID);
    ParserTestUtil.displayErrors(parsingResult);
    Assert.assertFalse(parsingResult.hasError(ParsingErrorLevel.ERROR));
}
Also used : Path(java.nio.file.Path) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) Test(org.junit.Test)

Example 8 with ArchiveRoot

use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.

the class ComplexPropertyMergeTest method postConstruct.

@PostConstruct
public void postConstruct() throws Throwable {
    if (!INITIALIZED) {
        if (Files.exists(Paths.get(alienRepoDir))) {
            try {
                FileUtil.delete(Paths.get(alienRepoDir));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        SecurityTestUtils.setTestAuthentication(Role.ADMIN);
        alienDAO.delete(Csar.class, QueryBuilders.matchAllQuery());
        String normativeLocalName = "tosca-normative-types";
        repositoryManager.cloneOrCheckout(artifactsDirectory, "https://github.com/alien4cloud/tosca-normative-types.git", "1.2.0", normativeLocalName);
        Path typesPath = artifactsDirectory.resolve(normativeLocalName);
        Path typesZipPath = artifactsDirectory.resolve(normativeLocalName + ".zip");
        FileUtil.zip(typesPath, typesZipPath);
        ParsingResult<Csar> result = archiveUploadService.upload(typesZipPath, CSARSource.OTHER, AlienConstants.GLOBAL_WORKSPACE_ID);
        ParserTestUtil.displayErrors(result);
        AbstractToscaParserSimpleProfileTest.assertNoBlocker(result);
        INITIALIZED = true;
    }
    ParsingResult<ArchiveRoot> result = applicationUtil.parseYamlTopology("src/test/resources/data/csars/merge_complex/tosca");
    // AbstractToscaParserSimpleProfileTest.assertNoBlocker(result);
    topology = result.getResult().getTopology();
    topology.setId(UUID.randomUUID().toString());
    topology.setWorkspace(AlienConstants.GLOBAL_WORKSPACE_ID);
}
Also used : Path(java.nio.file.Path) Csar(org.alien4cloud.tosca.model.Csar) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) IOException(java.io.IOException) PostConstruct(javax.annotation.PostConstruct)

Example 9 with ArchiveRoot

use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.

the class MockAmazonLocationConfigurer method addToAchive.

private void addToAchive(List<PluginArchive> archives, String path) throws ParsingException {
    Path archivePath = selfContext.getPluginPath().resolve(path);
    // Parse the archives
    ParsingResult<ArchiveRoot> result = archiveParser.parseDir(archivePath, AlienConstants.GLOBAL_WORKSPACE_ID);
    PluginArchive pluginArchive = new PluginArchive(result.getResult(), archivePath);
    archives.add(pluginArchive);
}
Also used : Path(java.nio.file.Path) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) PluginArchive(alien4cloud.orchestrators.plugin.model.PluginArchive)

Example 10 with ArchiveRoot

use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.

the class ToscaParserAlien140Test method testServiceRelationshipSubstitution.

@Test
public void testServiceRelationshipSubstitution() throws FileNotFoundException, ParsingException {
    Mockito.reset(csarRepositorySearchService);
    Mockito.when(csarRepositorySearchService.getArchive("tosca-normative-types", "1.0.0-ALIEN14")).thenReturn(Mockito.mock(Csar.class));
    NodeType mockRoot = Mockito.mock(NodeType.class);
    Mockito.when(mockRoot.isAbstract()).thenReturn(true);
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(NodeType.class), Mockito.eq("tosca.nodes.Root"), Mockito.any(Set.class))).thenReturn(mockRoot);
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(CapabilityType.class), Mockito.eq("tosca.capabilities.Root"), Mockito.any(Set.class))).thenReturn(Mockito.mock(CapabilityType.class));
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(RelationshipType.class), Mockito.eq("tosca.relationships.Root"), Mockito.any(Set.class))).thenReturn(Mockito.mock(RelationshipType.class));
    ParsingResult<ArchiveRoot> parsingResult = parser.parseFile(Paths.get(getRootDirectory(), "substitution_mapping_service_relationship.yml"));
    Assert.assertEquals(0, parsingResult.getContext().getParsingErrors().size());
    ArchiveRoot archiveRoot = parsingResult.getResult();
    Assert.assertNotNull(archiveRoot.getArchive());
    Assert.assertEquals(getToscaVersion(), archiveRoot.getArchive().getToscaDefinitionsVersion());
    Assert.assertEquals("org.alien4cloud.relationships.test.MyRelationship", archiveRoot.getTopology().getSubstitutionMapping().getCapabilities().get("subst_capa").getServiceRelationshipType());
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) CapabilityType(org.alien4cloud.tosca.model.types.CapabilityType) Set(java.util.Set) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) NodeType(org.alien4cloud.tosca.model.types.NodeType) RelationshipType(org.alien4cloud.tosca.model.types.RelationshipType) Test(org.junit.Test)

Aggregations

ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)78 Test (org.junit.Test)45 Csar (org.alien4cloud.tosca.model.Csar)27 Set (java.util.Set)26 NodeType (org.alien4cloud.tosca.model.types.NodeType)26 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)16 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)14 ParsingError (alien4cloud.tosca.parser.ParsingError)13 Path (java.nio.file.Path)11 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)9 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)8 Node (org.yaml.snakeyaml.nodes.Node)8 PluginArchive (alien4cloud.orchestrators.plugin.model.PluginArchive)6 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)6 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)6 ParsingException (alien4cloud.tosca.parser.ParsingException)5 Map (java.util.Map)5 Topology (org.alien4cloud.tosca.model.templates.Topology)5 ComplexPropertyValue (org.alien4cloud.tosca.model.definitions.ComplexPropertyValue)4 ScalarPropertyValue (org.alien4cloud.tosca.model.definitions.ScalarPropertyValue)4