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));
}
}
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));
}
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);
}
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);
}
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());
}
Aggregations