DriverInjection { public static void setDriverProperty(TRelationshipTemplate relationshipTemplate, TDeploymentArtifact driverDeploymentArtifact) throws Exception { QName DAArtifactTemplateQName = driverDeploymentArtifact.getArtifactRef(); ArtifactTemplateId artifactTemplateId = new ArtifactTemplateId(DAArtifactTemplateQName); TArtifactTemplate artifactTemplate = RepositoryFactory.getRepository().getElement(artifactTemplateId); Map<String, String> artifactProperties = ModelUtilities.getPropertiesKV(artifactTemplate); Map<String, String> relationshipProperties = ModelUtilities.getPropertiesKV(relationshipTemplate); if ((artifactProperties != null) && (relationshipProperties != null) && artifactProperties.containsKey("Driver") && relationshipProperties.containsKey("Driver")) { relationshipProperties.put("Driver", artifactProperties.get("Driver")); relationshipTemplate.getProperties().setKVProperties(relationshipProperties); } else { throw new WineryRepositoryException("No Property found to set to the driver classname"); } }  static TTopologyTemplate injectDriver(TTopologyTemplate topologyTemplate); static void setDriverProperty(TRelationshipTemplate relationshipTemplate, TDeploymentArtifact driverDeploymentArtifact);  }
@Test public void setDriverProperty() throws Exception { setRevisionTo("d8ee55deecf37f5052d27807df691a7b70ec50f2"); ServiceTemplateId id = new ServiceTemplateId("http: 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")); }