Search in sources :

Example 11 with ServiceTemplateId

use of org.eclipse.winery.common.ids.definitions.ServiceTemplateId 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 12 with ServiceTemplateId

use of org.eclipse.winery.common.ids.definitions.ServiceTemplateId 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 13 with ServiceTemplateId

use of org.eclipse.winery.common.ids.definitions.ServiceTemplateId in project winery by eclipse.

the class SplittingTest method initialize.

@Before
public void initialize() throws Exception {
    ServiceTemplateId id = new ServiceTemplateId("http://www.example.org", "ST", false);
    ServiceTemplateId id2 = new ServiceTemplateId("http://opentosca.org/servicetemplates", "FlinkApp_Demo_Small_On_OpenStack", false);
    assertTrue(RepositoryFactory.getRepository().exists(id));
    assertTrue(RepositoryFactory.getRepository().exists(id2));
    final TServiceTemplate serviceTemplate = this.repository.getElement(id);
    topologyTemplate = serviceTemplate.getTopologyTemplate();
    topologyTemplate2 = serviceTemplate.getTopologyTemplate();
}
Also used : ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) Before(org.junit.Before)

Example 14 with ServiceTemplateId

use of org.eclipse.winery.common.ids.definitions.ServiceTemplateId 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);
    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());
    }
    assertEquals(expectedIds, Ids);
}
Also used : ArrayList(java.util.ArrayList) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) Test(org.junit.Test)

Example 15 with ServiceTemplateId

use of org.eclipse.winery.common.ids.definitions.ServiceTemplateId in project winery by eclipse.

the class ServiceTemplatesResource method getXaaSPackageTemplates.

private Collection<ServiceTemplateId> getXaaSPackageTemplates() {
    Collection<AbstractComponentInstanceResource> templates = this.getAll();
    Collection<ServiceTemplateId> xaasPackages = new ArrayList<ServiceTemplateId>();
    for (AbstractComponentInstanceResource resource : templates) {
        if (resource instanceof ServiceTemplateResource) {
            ServiceTemplateResource stRes = (ServiceTemplateResource) resource;
            TTags tags = stRes.getServiceTemplate().getTags();
            if (tags == null) {
                continue;
            }
            int check = 0;
            for (TTag tag : tags.getTag()) {
                switch(tag.getName()) {
                    case "xaasPackageNode":
                    case "xaasPackageArtifactType":
                    case "xaasPackageDeploymentArtifact":
                        check++;
                        break;
                    default:
                        break;
                }
            }
            if (check == 3) {
                xaasPackages.add((ServiceTemplateId) stRes.getId());
            }
        }
    }
    return xaasPackages;
}
Also used : TTag(org.eclipse.winery.model.tosca.TTag) AbstractComponentInstanceResource(org.eclipse.winery.repository.rest.resources._support.AbstractComponentInstanceResource) TTags(org.eclipse.winery.model.tosca.TTags) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId)

Aggregations

ServiceTemplateId (org.eclipse.winery.common.ids.definitions.ServiceTemplateId)34 QName (javax.xml.namespace.QName)12 Test (org.junit.Test)12 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 URI (java.net.URI)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)6 RelationshipTypeId (org.eclipse.winery.common.ids.definitions.RelationshipTypeId)5 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)5 POST (javax.ws.rs.POST)4 ArtifactTemplateId (org.eclipse.winery.common.ids.definitions.ArtifactTemplateId)4 NonNull (org.eclipse.jdt.annotation.NonNull)3 CapabilityTypeId (org.eclipse.winery.common.ids.definitions.CapabilityTypeId)3 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)3 RequirementTypeId (org.eclipse.winery.common.ids.definitions.RequirementTypeId)3 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)3 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)3 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)3