test_class.file: org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/driverspecificationandinjection/DriverInjectionTest.java
test_class.identifier: DriverInjectionTest
test_class.superclass: extends TestWithGitBackedRepository
test_case.body: @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"));
      }
test_case.class_method_signature: DriverInjectionTest.injectDriver()
test_case.full_signature: @Test public void injectDriver()
test_case.identifier: injectDriver
test_case.invocations: setRevisionTo getTopologyTemplate getElement injectDriver getNodeTemplate getDeploymentArtifact getDeploymentArtifacts forEach stream add getName getRelationshipTemplate assertEquals size assertTrue contains assertTrue contains assertEquals get getPropertiesKV
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void injectDriver()
focal_class.file: org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/driverspecificationandinjection/DriverInjection.java
focal_class.identifier: DriverInjection
focal_class.class_method_signature: DriverInjection.injectDriver(TTopologyTemplate topologyTemplate)
focal_class.full_signature: public static TTopologyTemplate injectDriver(TTopologyTemplate topologyTemplate)
focal_class.identifier: injectDriver
focal_class.modifiers: public static
focal_class.parameters: (TTopologyTemplate topologyTemplate)
focal_class.return: TTopologyTemplate
focal_class.signature: TTopologyTemplate injectDriver(TTopologyTemplate topologyTemplate)
focal_class.class_method_signature: DriverInjection.setDriverProperty(TRelationshipTemplate relationshipTemplate, TDeploymentArtifact driverDeploymentArtifact)
focal_class.full_signature: public static void setDriverProperty(TRelationshipTemplate relationshipTemplate, TDeploymentArtifact driverDeploymentArtifact)
focal_class.identifier: setDriverProperty
focal_class.modifiers: public static
focal_class.parameters: (TRelationshipTemplate relationshipTemplate, TDeploymentArtifact driverDeploymentArtifact)
focal_class.return: void
focal_class.signature: void setDriverProperty(TRelationshipTemplate relationshipTemplate, TDeploymentArtifact driverDeploymentArtifact)
focal_method.body: 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);
                      }
                      //concrete DAs from the delivering Node Template must not be deleted. They are uploaded by the OpenTOSCA Container but not used.
                      nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact().remove(abstractDA);
                  } else {
                      throw new WineryRepositoryException("No concrete DA found for the abstract DA");
                  }
              }
          }
          return topologyTemplate;
      }
focal_method.class_method_signature: DriverInjection.injectDriver(TTopologyTemplate topologyTemplate)
focal_method.full_signature: public static TTopologyTemplate injectDriver(TTopologyTemplate topologyTemplate)
focal_method.identifier: injectDriver
focal_method.invocations: getNodeTemplatesWithAbstractDAs collect filter stream getDeploymentArtifact getDeploymentArtifacts getAbstract getArtifactTypeOfDA toList getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode keySet getSuitableConcreteDA get add getDeploymentArtifact getDeploymentArtifacts setDriverProperty remove getDeploymentArtifact getDeploymentArtifacts
focal_method.modifiers: public static
focal_method.parameters: (TTopologyTemplate topologyTemplate)
focal_method.return: TTopologyTemplate
focal_method.signature: TTopologyTemplate injectDriver(TTopologyTemplate topologyTemplate)