Search in sources :

Example 6 with TTopologyTemplate

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;
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate)

Example 7 with TTopologyTemplate

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);
}
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 TTopologyTemplate

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

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"));
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) Test(org.junit.Test)

Example 10 with TTopologyTemplate

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);
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) AbstractResourceTest(org.eclipse.winery.repository.rest.resources.AbstractResourceTest) Test(org.junit.Test)

Aggregations

TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)21 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)10 Test (org.junit.Test)8 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)7 ArrayList (java.util.ArrayList)6 TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)6 ServiceTemplateId (org.eclipse.winery.common.ids.definitions.ServiceTemplateId)5 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)4 IOException (java.io.IOException)3 List (java.util.List)3 QName (javax.xml.namespace.QName)3 TRequirement (org.eclipse.winery.model.tosca.TRequirement)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 WebResource (com.sun.jersey.api.client.WebResource)2 URI (java.net.URI)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 JAXBException (javax.xml.bind.JAXBException)2 TDocumentation (org.eclipse.winery.model.tosca.TDocumentation)2 Splitting (org.eclipse.winery.repository.splitting.Splitting)2