Splitting { protected List<TNodeTemplate> getNodeTemplatesWhichPredecessorsHasNoPredecessors(TTopologyTemplate topologyTemplate) { List<TNodeTemplate> nodeTemplates = ModelUtilities.getAllNodeTemplates(topologyTemplate); List<TNodeTemplate> predecessorsOfpredecessors = new ArrayList<>(); predecessorsOfpredecessors.clear(); List<TNodeTemplate> candidates = new ArrayList<>(); for (TNodeTemplate nodeTemplate : nodeTemplates) { List<TNodeTemplate> allPredecessors = getHostedOnPredecessorsOfNodeTemplate(topologyTemplate, nodeTemplate); if (!allPredecessors.isEmpty()) { predecessorsOfpredecessors.clear(); for (TNodeTemplate predecessor : allPredecessors) { predecessorsOfpredecessors.addAll(getHostedOnPredecessorsOfNodeTemplate(topologyTemplate, predecessor)); } if (predecessorsOfpredecessors.isEmpty()) { candidates.add(nodeTemplate); } } } return candidates; }  ServiceTemplateId splitTopologyOfServiceTemplate(ServiceTemplateId id); ServiceTemplateId matchTopologyOfServiceTemplate(ServiceTemplateId id); ServiceTemplateId composeServiceTemplates(String composedSolutionServiceTemplateID, List<ServiceTemplateId> serviceTemplateIds); void resolveTopologyTemplate(ServiceTemplateId serviceTemplateId); boolean checkValidTopology(TTopologyTemplate topologyTemplate); TTopologyTemplate split(TTopologyTemplate topologyTemplate); Map<String, List<TTopologyTemplate>> getHostingInjectionOptions(TTopologyTemplate topologyTemplate); Map<String, List<TTopologyTemplate>> getHostingMatchingOptionsWithDefaultLabeling(TTopologyTemplate topologyTemplate); TTopologyTemplate hostMatchingWithDefaultHostSelection(TTopologyTemplate topologyTemplate); TTopologyTemplate connectionMatchingWithDefaultConnectorSelection(TTopologyTemplate topologyTemplate); TTopologyTemplate injectNodeTemplates(TTopologyTemplate topologyTemplate, Map<String, TTopologyTemplate> injectNodes, InjectRemoval removal); Map<String, List<TTopologyTemplate>> getConnectionInjectionOptions(TTopologyTemplate topologyTemplate); TTopologyTemplate injectConnectionNodeTemplates(TTopologyTemplate topologyTemplate, Map<String, TTopologyTemplate> selectedConnectionFragments); Map<TNodeTemplate, Set<TNodeTemplate>> computeTransitiveClosure(TTopologyTemplate topologyTemplate); Map<TRequirement, String> getOpenRequirementsAndMatchingBasisCapabilityTypeNames(TTopologyTemplate topologyTemplate); List<TRequirement> getOpenRequirements(TTopologyTemplate topologyTemplate); TRelationshipType getBasisRelationshipType(QName relationshipTypeQName);  }
@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)); }
@Test public void testgetPredecessorsWhichPredecessorsHasNoPredecessors() { TNodeTemplate nt1 = topologyTemplate.getNodeTemplateOrRelationshipTemplate() .stream() .filter(x -> x instanceof TNodeTemplate) .map(TNodeTemplate.class::cast) .filter(nt -> nt.getId().equals("NT1_3")) .findAny() .get(); assertEquals(nt1.getId(), splitting.getNodeTemplatesWhichPredecessorsHasNoPredecessors(topologyTemplate).get(0).getId()); }