Search in sources :

Example 1 with YTTopologyTemplateDefinition

use of org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition in project winery by eclipse.

the class YamlRepository method replaceTopologyTemplate.

private YTServiceTemplate replaceTopologyTemplate(YTServiceTemplate newServiceTemplate, YTServiceTemplate existingServiceTemplate) {
    if (newServiceTemplate.getTopologyTemplate() == null) {
        return existingServiceTemplate;
    }
    if (existingServiceTemplate.getTopologyTemplate() == null) {
        existingServiceTemplate.setTopologyTemplate(new YTTopologyTemplateDefinition.Builder().build());
    }
    YTTopologyTemplateDefinition newTopologyTemplate = newServiceTemplate.getTopologyTemplate();
    YTTopologyTemplateDefinition existingTopologyTemplate = existingServiceTemplate.getTopologyTemplate();
    existingTopologyTemplate.setPolicies(newTopologyTemplate.getPolicies());
    existingTopologyTemplate.setNodeTemplates(newTopologyTemplate.getNodeTemplates());
    existingTopologyTemplate.setRelationshipTemplates(newTopologyTemplate.getRelationshipTemplates());
    if (newTopologyTemplate.getInputs() != null) {
        existingTopologyTemplate.setInputs(newTopologyTemplate.getInputs());
    }
    if (newTopologyTemplate.getOutputs() != null) {
        existingTopologyTemplate.setOutputs(newTopologyTemplate.getOutputs());
    }
    existingTopologyTemplate.setDescription(newTopologyTemplate.getDescription());
    existingTopologyTemplate.setGroups(newTopologyTemplate.getGroups());
    return existingServiceTemplate;
}
Also used : YTTopologyTemplateDefinition(org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition)

Example 2 with YTTopologyTemplateDefinition

use of org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition in project winery by eclipse.

the class FromCanonical method convert.

public YTTopologyTemplateDefinition convert(TServiceTemplate node) {
    // substitution mappings are an extension feature and currently not supported for YAML
    if (Objects.isNull(node)) {
        return null;
    }
    TTopologyTemplate topologyTemplate = node.getTopologyTemplate();
    if (Objects.isNull(topologyTemplate)) {
        return null;
    }
    YTTopologyTemplateDefinition.Builder builder = new YTTopologyTemplateDefinition.Builder().setDescription(convertDocumentation(topologyTemplate.getDocumentation())).setNodeTemplates(convert(topologyTemplate.getNodeTemplates(), topologyTemplate.getRelationshipTemplates())).setRelationshipTemplates(convert(topologyTemplate.getRelationshipTemplates())).setPolicies(convert(topologyTemplate.getPolicies())).setGroups(convert(topologyTemplate.getGroups()));
    if (topologyTemplate.getInputs() != null) {
        builder.setInputs(convert(topologyTemplate.getInputs()));
    }
    if (topologyTemplate.getOutputs() != null) {
        builder.setOutputs(convert(topologyTemplate.getOutputs()));
    }
    return builder.build();
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) YTTopologyTemplateDefinition(org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition)

Example 3 with YTTopologyTemplateDefinition

use of org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition in project winery by eclipse.

the class YamlReaderTest method testBasicTopologyTemplate.

@DisplayName("Basic Topology Template Reader Test")
@Test
public void testBasicTopologyTemplate() throws Exception {
    YamlReader reader = new YamlReader();
    InputStream is = getClass().getClassLoader().getResourceAsStream("yaml/simple-tests/valid-topology_templates-1_3.yml");
    YTServiceTemplate serviceTemplate = reader.parse(is);
    Assertions.assertNotNull(serviceTemplate);
    YTTopologyTemplateDefinition topoTemplate = serviceTemplate.getTopologyTemplate();
    Assertions.assertNotNull(topoTemplate);
    Assertions.assertEquals(topoTemplate.getPolicies().size(), 2);
    Assertions.assertEquals(topoTemplate.getNodeTemplates().size(), 1);
    Assertions.assertEquals(topoTemplate.getRelationshipTemplates().size(), 1);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) YTTopologyTemplateDefinition(org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition) YamlReader(org.eclipse.winery.repository.converter.reader.YamlReader) AbstractConverterTest(org.eclipse.winery.repository.converter.AbstractConverterTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with YTTopologyTemplateDefinition

use of org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition in project winery by eclipse.

the class YamlReaderTest method testPolicyDefinitionsAsMap.

@Test
public void testPolicyDefinitionsAsMap() throws Exception {
    YamlReader reader = new YamlReader();
    InputStream is = getClass().getClassLoader().getResourceAsStream("yaml/simple-tests/wrong-policy-map-in-tt.yml");
    YTServiceTemplate template = reader.parse(is);
    Assertions.assertNotNull(template);
    YTTopologyTemplateDefinition topologyTemplate = template.getTopologyTemplate();
    Assertions.assertNotNull(topologyTemplate);
    Assertions.assertEquals(0, topologyTemplate.getPolicies().size());
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) YTTopologyTemplateDefinition(org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition) YamlReader(org.eclipse.winery.repository.converter.reader.YamlReader) AbstractConverterTest(org.eclipse.winery.repository.converter.AbstractConverterTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with YTTopologyTemplateDefinition

use of org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition 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());
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) YTTopologyTemplateDefinition(org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition) YamlReader(org.eclipse.winery.repository.converter.reader.YamlReader) AbstractConverterTest(org.eclipse.winery.repository.converter.AbstractConverterTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

YTTopologyTemplateDefinition (org.eclipse.winery.model.tosca.yaml.YTTopologyTemplateDefinition)5 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 YTServiceTemplate (org.eclipse.winery.model.tosca.yaml.YTServiceTemplate)3 AbstractConverterTest (org.eclipse.winery.repository.converter.AbstractConverterTest)3 YamlReader (org.eclipse.winery.repository.converter.reader.YamlReader)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)1 DisplayName (org.junit.jupiter.api.DisplayName)1