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