use of org.eclipse.winery.model.tosca.TTopologyTemplate in project winery by eclipse.
the class TOSCAModelHelper method createTTopologyTemplate.
public static TTopologyTemplate createTTopologyTemplate(List<TNodeTemplate> nodeTemplates, List<TRelationshipTemplate> relationshipTemplates) {
TTopologyTemplate template = new TTopologyTemplate();
template.setNodeTemplates(nodeTemplates);
template.setRelationshipTemplates(relationshipTemplates);
return template;
}
use of org.eclipse.winery.model.tosca.TTopologyTemplate 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.TTopologyTemplate 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.TTopologyTemplate in project winery by eclipse.
the class DriverInjectionTest method setDriverProperty.
@Test
public void setDriverProperty() 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();
TRelationshipTemplate relationshipTemplate = topologyTemplate.getRelationshipTemplate("con_71");
TDeploymentArtifact deploymentArtifact = topologyTemplate.getNodeTemplate("dressageequipment").getDeploymentArtifacts().getDeploymentArtifact().stream().filter(da -> da.getName().equalsIgnoreCase("DressageEquipment_Pony")).findFirst().get();
DriverInjection.setDriverProperty(relationshipTemplate, deploymentArtifact);
assertEquals("org.test.dressagedriver", ModelUtilities.getPropertiesKV(relationshipTemplate).get("Driver"));
}
use of org.eclipse.winery.model.tosca.TTopologyTemplate in project winery by eclipse.
the class TopologyTemplateResourceTest method strawStallTopologyTemplateJsonCanBeParsed.
@Test
public void strawStallTopologyTemplateJsonCanBeParsed() throws Exception {
final String jsonStr = AbstractResourceTest.readFromClasspath("entitytypes/servicetemplates/straw-stall.json");
final TTopologyTemplate topologyTemplate = BackendUtils.mapper.readValue(jsonStr, TTopologyTemplate.class);
}
Aggregations