Search in sources :

Example 1 with XTNodeTemplate

use of org.eclipse.winery.model.tosca.xml.XTNodeTemplate in project winery by eclipse.

the class RemoveEmptyListsTest method emptyPropertiesAndPoliciesListsRemovedFromNodeTemplate.

@Test
public void emptyPropertiesAndPoliciesListsRemovedFromNodeTemplate() {
    XTTopologyTemplate topologyTemplate = new XTTopologyTemplate.Builder().build();
    XTNodeTemplate nodeTemplate = new XTNodeTemplate.Builder("test", QName.valueOf("{ns}test")).build();
    topologyTemplate.getNodeTemplateOrRelationshipTemplate().add(nodeTemplate);
    nodeTemplate.setProperties(new XTEntityTemplate.Properties());
    nodeTemplate.setPolicies(new ArrayList<>());
    assertNotNull(((XTNodeTemplate) topologyTemplate.getNodeTemplateOrRelationshipTemplate().get(0)).getPolicies());
    assertNotNull(topologyTemplate.getNodeTemplateOrRelationshipTemplate().get(0).getProperties());
    // preconditions fulfilled
    RemoveEmptyLists removeEmptyLists = new RemoveEmptyLists();
    removeEmptyLists.removeEmptyLists(topologyTemplate);
    assertNull(((XTNodeTemplate) topologyTemplate.getNodeTemplateOrRelationshipTemplate().get(0)).getPolicies());
    assertNull(topologyTemplate.getNodeTemplateOrRelationshipTemplate().get(0).getProperties());
}
Also used : XTEntityTemplate(org.eclipse.winery.model.tosca.xml.XTEntityTemplate) XTNodeTemplate(org.eclipse.winery.model.tosca.xml.XTNodeTemplate) XTTopologyTemplate(org.eclipse.winery.model.tosca.xml.XTTopologyTemplate) Test(org.junit.jupiter.api.Test)

Example 2 with XTNodeTemplate

use of org.eclipse.winery.model.tosca.xml.XTNodeTemplate in project winery by eclipse.

the class Visitor method visit.

public void visit(XTTopologyTemplate topologyTemplate) {
    Objects.requireNonNull(topologyTemplate);
    visit((XTExtensibleElements) topologyTemplate);
    for (XTNodeTemplate nodeTemplate : topologyTemplate.getNodeTemplates()) {
        nodeTemplate.accept(this);
    }
    for (XTRelationshipTemplate relationshipTemplate : topologyTemplate.getRelationshipTemplates()) {
        relationshipTemplate.accept(this);
    }
// metamodel does not offer more children
}
Also used : XTNodeTemplate(org.eclipse.winery.model.tosca.xml.XTNodeTemplate) XTRelationshipTemplate(org.eclipse.winery.model.tosca.xml.XTRelationshipTemplate)

Aggregations

XTNodeTemplate (org.eclipse.winery.model.tosca.xml.XTNodeTemplate)2 XTEntityTemplate (org.eclipse.winery.model.tosca.xml.XTEntityTemplate)1 XTRelationshipTemplate (org.eclipse.winery.model.tosca.xml.XTRelationshipTemplate)1 XTTopologyTemplate (org.eclipse.winery.model.tosca.xml.XTTopologyTemplate)1 Test (org.junit.jupiter.api.Test)1