use of org.eclipse.winery.repository.converter.reader.YamlReader in project winery by eclipse.
the class YamlReaderTest method testPolicyDefinitionsAsList.
@Test
public void testPolicyDefinitionsAsList() throws Exception {
YamlReader reader = new YamlReader();
InputStream is = getClass().getClassLoader().getResourceAsStream("yaml/simple-tests/valid-topology_templates-1_3.yml");
YTServiceTemplate template = reader.parse(is);
Assertions.assertNotNull(template);
YTTopologyTemplateDefinition topologyTemplate = template.getTopologyTemplate();
Assertions.assertNotNull(topologyTemplate);
Assertions.assertEquals(2, topologyTemplate.getPolicies().size());
}
use of org.eclipse.winery.repository.converter.reader.YamlReader in project winery by eclipse.
the class YamlReaderTest method testSupportedInterfaceDefinitions.
@Test
public void testSupportedInterfaceDefinitions() throws Exception {
YamlReader reader = new YamlReader();
InputStream is = getClass().getClassLoader().getResourceAsStream("yaml/supported_interfaces.yml");
YTServiceTemplate template = reader.parse(is);
Assertions.assertNotNull(template);
YTNodeType server = template.getNodeTypes().get("server");
Assertions.assertEquals(2, server.getArtifacts().size());
YTInterfaceDefinition standard = server.getInterfaces().get("Standard");
Assertions.assertEquals(2, standard.getOperations().size());
Assertions.assertEquals(1, standard.getInputs().size());
}
use of org.eclipse.winery.repository.converter.reader.YamlReader in project winery by eclipse.
the class YamlCsarImporter method parseDefinitionsElement.
@Override
protected Optional<TDefinitions> parseDefinitionsElement(Path entryDefinitionsPath, final List<String> errors) {
YamlReader reader = new YamlReader();
YTServiceTemplate serviceTemplate;
try {
serviceTemplate = reader.parse(new FileInputStream(entryDefinitionsPath.toFile()));
String name = serviceTemplate.getMetadata().get("name");
if (name == null) {
// fallback to filename
name = entryDefinitionsPath.toString().substring(entryDefinitionsPath.toString().indexOf("__") + 2, entryDefinitionsPath.toString().indexOf(".tosca"));
}
ToCanonical converter = new ToCanonical(targetRepository);
return Optional.of(converter.convert(serviceTemplate, name, serviceTemplate.getMetadata().get("targetNamespace"), true));
} catch (MultiException | FileNotFoundException e) {
e.printStackTrace();
LOGGER.error("Could not read the given entry definition " + e.getMessage());
}
return Optional.empty();
}
Aggregations