Search in sources :

Example 6 with TNodeTemplate

use of org.eclipse.winery.model.tosca.TNodeTemplate in project winery by eclipse.

the class TOSCAModelHelper method createTOSCANodeOnlyProperties.

public static TOSCANode createTOSCANodeOnlyProperties(TOSCAModelPropertiesBuilder bldr) {
    TOSCANode node = new TOSCANode();
    node.setNodeTemplate(new TNodeTemplate());
    node.getNodeTemplate().setProperties(bldr.build());
    return node;
}
Also used : TOSCANode(org.eclipse.winery.compliance.model.TOSCANode) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Example 7 with TNodeTemplate

use of org.eclipse.winery.model.tosca.TNodeTemplate in project winery by eclipse.

the class BackendUtilsTest method testClone.

@Test
public void testClone() throws Exception {
    TTopologyTemplate topologyTemplate = new TTopologyTemplate();
    TNodeTemplate nt1 = new TNodeTemplate();
    TNodeTemplate nt2 = new TNodeTemplate();
    TNodeTemplate nt3 = new TNodeTemplate();
    nt1.setId("NT1");
    nt2.setId("NT2");
    nt3.setId("NT3");
    List<TEntityTemplate> entityTemplates = topologyTemplate.getNodeTemplateOrRelationshipTemplate();
    entityTemplates.add(nt1);
    entityTemplates.add(nt2);
    entityTemplates.add(nt3);
    TTopologyTemplate clone = BackendUtils.clone(topologyTemplate);
    List<TEntityTemplate> entityTemplatesClone = clone.getNodeTemplateOrRelationshipTemplate();
    Assert.assertEquals(entityTemplates, entityTemplatesClone);
}
Also used : TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.Test)

Example 8 with TNodeTemplate

use of org.eclipse.winery.model.tosca.TNodeTemplate in project winery by eclipse.

the class DriverInjectionTest method injectDriver.

@Test
public void injectDriver() throws Exception {
    setRevisionTo("d8ee55deecf37f5052d27807df691a7b70ec50f2");
    ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
    TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
    TTopologyTemplate tTopologyTemplate = DriverInjection.injectDriver(topologyTemplate);
    TNodeTemplate nodeTemplateWithAbstractDA = tTopologyTemplate.getNodeTemplate("shetland_pony");
    List<TDeploymentArtifact> deploymentArtifacts = nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact();
    List<String> deploymentArtifactNames = new ArrayList<>();
    deploymentArtifacts.stream().forEach(da -> deploymentArtifactNames.add(da.getName()));
    TRelationshipTemplate relationshipTemplate = tTopologyTemplate.getRelationshipTemplate("con_71");
    assertEquals(2, deploymentArtifacts.size());
    assertTrue(deploymentArtifactNames.contains("WesternEquipment_Pony"));
    assertTrue(deploymentArtifactNames.contains("DressageEquipment_Pony"));
    assertEquals("org.test.dressagedriver", ModelUtilities.getPropertiesKV(relationshipTemplate).get("Driver"));
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) ArrayList(java.util.ArrayList) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.Test)

Example 9 with TNodeTemplate

use of org.eclipse.winery.model.tosca.TNodeTemplate in project winery by eclipse.

the class BackendUtilsTest method relationshipTemplateIsSerializedAsRefInXml.

@Test
public void relationshipTemplateIsSerializedAsRefInXml() throws Exception {
    TTopologyTemplate minimalTopologyTemplate = new TTopologyTemplate();
    TNodeTemplate nt1 = new TNodeTemplate("nt1");
    minimalTopologyTemplate.addNodeTemplate(nt1);
    TNodeTemplate nt2 = new TNodeTemplate("nt2");
    minimalTopologyTemplate.addNodeTemplate(nt2);
    TRelationshipTemplate rt = new TRelationshipTemplate("rt");
    minimalTopologyTemplate.addRelationshipTemplate(rt);
    rt.setSourceNodeTemplate(nt1);
    rt.setTargetNodeTemplate(nt2);
    String minimalTopologyTemplateAsXmlString = "<TopologyTemplate xmlns=\"http://docs.oasis-open.org/tosca/ns/2011/12\" xmlns:ns3=\"http://www.eclipse.org/winery/model/selfservice\" xmlns:ns4=\"http://test.winery.opentosca.org\" xmlns:winery=\"http://www.opentosca.org/winery/extensions/tosca/2013/02/12\">\n" + "  <NodeTemplate id=\"nt1\"/>\n" + "  <NodeTemplate id=\"nt2\"/>\n" + "  <RelationshipTemplate id=\"rt\">\n" + "    <SourceElement ref=\"nt1\"/>\n" + "    <TargetElement ref=\"nt2\"/>\n" + "  </RelationshipTemplate>\n" + "</TopologyTemplate>";
    org.hamcrest.MatcherAssert.assertThat(BackendUtils.getXMLAsString(minimalTopologyTemplate), CompareMatcher.isIdenticalTo(minimalTopologyTemplateAsXmlString).ignoreWhitespace());
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.Test)

Example 10 with TNodeTemplate

use of org.eclipse.winery.model.tosca.TNodeTemplate in project winery by eclipse.

the class BackendUtilsTest method relationshipTemplateIsSerializedAsRefInJson.

@Test
public void relationshipTemplateIsSerializedAsRefInJson() throws Exception {
    TTopologyTemplate minimalTopologyTemplate = new TTopologyTemplate();
    TNodeTemplate nt1 = new TNodeTemplate("nt1");
    minimalTopologyTemplate.addNodeTemplate(nt1);
    TNodeTemplate nt2 = new TNodeTemplate("nt2");
    minimalTopologyTemplate.addNodeTemplate(nt2);
    TRelationshipTemplate rt = new TRelationshipTemplate("rt");
    minimalTopologyTemplate.addRelationshipTemplate(rt);
    rt.setSourceNodeTemplate(nt1);
    rt.setTargetNodeTemplate(nt2);
    String minimalTopologyTemplateAsJsonString = "{\"documentation\":[],\"any\":[],\"otherAttributes\":{},\"nodeTemplates\":[{\"id\":\"nt1\",\"documentation\":[],\"any\":[],\"otherAttributes\":{},\"minInstances\":1,\"maxInstances\":\"1\"},{\"id\":\"nt2\",\"documentation\":[],\"any\":[],\"otherAttributes\":{},\"minInstances\":1,\"maxInstances\":\"1\"}],\"relationshipTemplates\":[{\"documentation\":[],\"any\":[],\"otherAttributes\":{},\"id\":\"rt\",\"sourceElement\":{\"ref\":\"nt1\"},\"targetElement\":{\"ref\":\"nt2\"}}]}";
    JSONAssert.assertEquals(minimalTopologyTemplateAsJsonString, BackendUtils.Object2JSON(minimalTopologyTemplate), true);
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.Test)

Aggregations

TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)26 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)11 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)10 ArrayList (java.util.ArrayList)9 QName (javax.xml.namespace.QName)9 TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)8 Test (org.junit.Test)7 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)6 NodeTypeId (org.eclipse.winery.common.ids.definitions.NodeTypeId)6 ServiceTemplateId (org.eclipse.winery.common.ids.definitions.ServiceTemplateId)6 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 RelationshipTypeId (org.eclipse.winery.common.ids.definitions.RelationshipTypeId)4 RequirementTypeId (org.eclipse.winery.common.ids.definitions.RequirementTypeId)4 TOSCANode (org.eclipse.winery.compliance.model.TOSCANode)4 TDeploymentArtifacts (org.eclipse.winery.model.tosca.TDeploymentArtifacts)4 TRequirement (org.eclipse.winery.model.tosca.TRequirement)4 TOSCAModelHelper.createNodeTypeId (org.eclipse.winery.compliance.TOSCAModelHelper.createNodeTypeId)3 TOSCAModelHelper.createTNodeTemplate (org.eclipse.winery.compliance.TOSCAModelHelper.createTNodeTemplate)3