Search in sources :

Example 26 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();
    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.model.ids.definitions.ServiceTemplateId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.jupiter.api.Test)

Example 27 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().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.model.ids.definitions.ServiceTemplateId) Test(org.junit.jupiter.api.Test)

Example 28 with TTopologyTemplate

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

the class SplittingTest method st1nt2IsTheNodeTemplateWhichPredecessorsHasNoPredecessors.

@Test
public void st1nt2IsTheNodeTemplateWhichPredecessorsHasNoPredecessors() 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");
    TRelationshipTemplate rt = new TRelationshipTemplate();
    TRelationshipTemplate.SourceOrTargetElement targetElement = new TRelationshipTemplate.SourceOrTargetElement();
    targetElement.setRef(nt2);
    rt.setTargetElement(targetElement);
    TRelationshipTemplate.SourceOrTargetElement sourceElement = new TRelationshipTemplate.SourceOrTargetElement();
    sourceElement.setRef(nt1);
    rt.setSourceElement(sourceElement);
    TRelationshipTemplate rt2 = new TRelationshipTemplate();
    TRelationshipTemplate.SourceOrTargetElement targetElement1 = new TRelationshipTemplate.SourceOrTargetElement();
    targetElement1.setRef(nt1);
    rt2.setTargetElement(targetElement1);
    TRelationshipTemplate.SourceOrTargetElement sourceElement1 = new TRelationshipTemplate.SourceOrTargetElement();
    sourceElement1.setRef(nt3);
    rt2.setSourceElement(sourceElement1);
    List<TEntityTemplate> entityTemplates = topologyTemplate.getNodeTemplateOrRelationshipTemplate();
    entityTemplates.add(nt1);
    entityTemplates.add(nt2);
    entityTemplates.add(nt3);
    entityTemplates.add(rt);
    List<TNodeTemplate> expectedNodeTemplates = new ArrayList<>();
    expectedNodeTemplates.add(nt1);
    assertEquals(expectedNodeTemplates, splitting.getNodeTemplatesWhichPredecessorsHasNoPredecessors(topologyTemplate));
}
Also used : TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) ArrayList(java.util.ArrayList) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.jupiter.api.Test)

Example 29 with TTopologyTemplate

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

the class SplittingTest method testmatchingofSplittingTopology.

@Test
public void testmatchingofSplittingTopology() throws Exception {
    ServiceTemplateId serviceTemplateId = new ServiceTemplateId("http://opentosca.org/servicetemplates", "Abstract_PHPApp_MySQLDB_MotivatingScenario_Splitting-split", false);
    Assertions.assertTrue(this.repository.exists(serviceTemplateId));
    final TServiceTemplate serviceTemplate = repository.getElement(serviceTemplateId);
    TTopologyTemplate topologyTemplateMatching = serviceTemplate.getTopologyTemplate();
    List<String> expectedIds = Arrays.asList("PHP-5-WebApplication", "Java7", "MySQL-DB", "PHP-5-Module", "Apache-2.4", "Ubuntu-14.04-VM-OnPremiseIAAS", "OpenStack-Liberty-12-OnPremiseIAAS", "AmazonBeanstalk", "AmazonRDS");
    List<TNodeTemplate> NodeTemplates = splitting.hostMatchingWithDefaultHostSelection(topologyTemplateMatching).getNodeTemplateOrRelationshipTemplate().stream().filter(t -> t instanceof TNodeTemplate).map(TNodeTemplate.class::cast).collect(Collectors.toList());
    List<String> Ids = new ArrayList<>();
    for (TNodeTemplate nodeTemplate : NodeTemplates) {
        Ids.add(nodeTemplate.getId());
    }
    Assertions.assertEquals(expectedIds, Ids);
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ArrayList(java.util.ArrayList) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test)

Example 30 with TTopologyTemplate

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

the class MinExternalConnectionsTest method filter.

@Test
public void filter() throws Exception {
    ServiceTemplateId id = new ServiceTemplateId("http://www.winery.opentosca.org/test/targetallocation/servicetemplates", "MinExternalConnectionsTest1", false);
    TTopologyTemplate twoExternal = repository.getElement(id).getTopologyTemplate();
    ModelUtilities.setTargetLabel(twoExternal.getNodeTemplate("shetland_pony_2"), "PastureProvider");
    ModelUtilities.setTargetLabel(twoExternal.getNodeTemplate("shetland_pony_3"), "PastureProvider");
    TTopologyTemplate oneExternal = AllocationUtils.deepCopy(twoExternal);
    ModelUtilities.setTargetLabel(oneExternal.getNodeTemplate("shetland_pony_2"), "FieldProvider");
    ModelUtilities.setTargetLabel(oneExternal.getNodeTemplate("shetland_pony_3"), "FieldProvider");
    List<TopologyWrapper> topologies = new ArrayList<>();
    topologies.add(new TopologyWrapper(twoExternal));
    topologies.add(new TopologyWrapper(oneExternal));
    Criteria minExternalConnections = new MinExternalConnections(null, Integer.MAX_VALUE);
    List<TopologyWrapper> filtered = minExternalConnections.filter(topologies);
    assertEquals(1, filtered.size());
    TTopologyTemplate result = filtered.get(0).getTopology();
    assertEquals("PastureProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony")).get());
    assertEquals("FieldProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony_2")).get());
    assertEquals("FieldProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony_3")).get());
    assertEquals("FieldProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony_4")).get());
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ArrayList(java.util.ArrayList) TopologyWrapper(org.eclipse.winery.repository.targetallocation.util.TopologyWrapper) Criteria(org.eclipse.winery.repository.targetallocation.Criteria) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) Test(org.junit.jupiter.api.Test)

Aggregations

TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)158 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)112 ArrayList (java.util.ArrayList)85 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)62 List (java.util.List)59 QName (javax.xml.namespace.QName)55 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)55 Test (org.junit.jupiter.api.Test)51 Map (java.util.Map)48 HashMap (java.util.HashMap)47 LinkedHashMap (java.util.LinkedHashMap)42 TNodeType (org.eclipse.winery.model.tosca.TNodeType)42 ModelUtilities (org.eclipse.winery.model.tosca.utils.ModelUtilities)38 IRepository (org.eclipse.winery.repository.backend.IRepository)38 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)36 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)35 Objects (java.util.Objects)34 IOException (java.io.IOException)32 HashSet (java.util.HashSet)32 Collectors (java.util.stream.Collectors)32