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