DriverInjection { public static TTopologyTemplate injectDriver(TTopologyTemplate topologyTemplate) throws Exception { List<TNodeTemplate> nodeTemplatesWithAbstractDA = DASpecification.getNodeTemplatesWithAbstractDAs(topologyTemplate); for (TNodeTemplate nodeTemplateWithAbstractDA : nodeTemplatesWithAbstractDA) { List<TDeploymentArtifact> abstractDAsAttachedToNodeTemplate = nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact().stream() .filter(da -> DASpecification.getArtifactTypeOfDA(da).getAbstract() == TBoolean.YES) .collect(Collectors.toList()); for (TDeploymentArtifact abstractDA : abstractDAsAttachedToNodeTemplate) { Map<TRelationshipTemplate, TNodeTemplate> nodeTemplatesWithConcreteDA = DASpecification.getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode(nodeTemplateWithAbstractDA, abstractDA, topologyTemplate); if (nodeTemplatesWithConcreteDA != null) { for (TRelationshipTemplate relationshipTemplate : nodeTemplatesWithConcreteDA.keySet()) { TDeploymentArtifact concreteDeploymentArtifact = DASpecification.getSuitableConcreteDA(abstractDA, nodeTemplatesWithConcreteDA.get(relationshipTemplate)); nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact().add(concreteDeploymentArtifact); setDriverProperty(relationshipTemplate, concreteDeploymentArtifact); } nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact().remove(abstractDA); } else { throw new WineryRepositoryException("No concrete DA found for the abstract DA"); } } } return topologyTemplate; }  static TTopologyTemplate injectDriver(TTopologyTemplate topologyTemplate); static void setDriverProperty(TRelationshipTemplate relationshipTemplate, TDeploymentArtifact driverDeploymentArtifact);  }
@Test public void injectDriver() throws Exception { setRevisionTo("d8ee55deecf37f5052d27807df691a7b70ec50f2"); ServiceTemplateId id = new ServiceTemplateId("http: 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")); }