test_class.file: org.eclipse.winery.repository/src/test/java/org/eclipse/winery/repository/targetallocation/criteria/minhosts/MinHostsTest.java
test_class.identifier: MinHostsTest
test_class.superclass: extends TestWithGitBackedRepository
test_case.body: @Test
      public void testNoTargetLabelsPresent() throws Exception {
          ServiceTemplateId id = new ServiceTemplateId("http://www.winery.opentosca.org/test/targetallocation/servicetemplates",
              "TargetAllocationMinHostsTest4", false);
          TopologyWrapper topology = new TopologyWrapper(repository.getElement(id).getTopologyTemplate());
          Criteria minHosts = new MinHosts(null, Integer.MAX_VALUE);
          List<String> ntIdsWithoutTargetLabel = topology.getTopLevelNTs().stream()
              .filter(nt -> !ModelUtilities.getTargetLabel(nt).isPresent()).map(HasId::getId).collect(Collectors.toList());
  
          List<TopologyWrapper> topologies = minHosts.allocate(topology);
          assertEquals(2, topologies.size());
          TTopologyTemplate topology1 = topologies.get(0).getTopology();
          TTopologyTemplate topology2 = topologies.get(1).getTopology();
          assertEquals(17, topology1.getNodeTemplateOrRelationshipTemplate().size());
          assertEquals(17, topology2.getNodeTemplateOrRelationshipTemplate().size());
  
          List<String> types1 = new ArrayList<>();
          for (TNodeTemplate nodeTemplate : topology1.getNodeTemplates()) {
              types1.add(nodeTemplate.getType().getLocalPart());
          }
          assertEquals(10, types1.size());
          assertEquals(7, types1.stream().filter(type -> type.equalsIgnoreCase("shetland_pony")).count());
          assertEquals(2, types1.stream().filter(type -> type.equalsIgnoreCase("pasture")).count());
          for (TNodeTemplate nodeTemplate : topologies.get(0).getTopLevelNTs()) {
              if (ntIdsWithoutTargetLabel.contains(nodeTemplate.getId())) {
                  assertEquals("pasture", topologies.get(0).getHostedOnSuccessor(nodeTemplate).getType().getLocalPart());
              }
          }
  
          List<String> types2 = new ArrayList<>();
          for (TNodeTemplate nodeTemplate : topology2.getNodeTemplates()) {
              types2.add(nodeTemplate.getType().getLocalPart());
          }
          assertEquals(10, types2.size());
          assertEquals(7, types2.stream().filter(type -> type.equalsIgnoreCase("shetland_pony")).count());
          assertEquals(2, types2.stream().filter(type -> type.equalsIgnoreCase("field_-w1-wip1")).count());
          for (TNodeTemplate nodeTemplate : topologies.get(1).getTopLevelNTs()) {
              if (ntIdsWithoutTargetLabel.contains(nodeTemplate.getId())) {
                  assertEquals("field_-w1-wip1", topologies.get(1).getHostedOnSuccessor(nodeTemplate).getType().getLocalPart());
              }
          }
      }
test_case.class_method_signature: MinHostsTest.testNoTargetLabelsPresent()
test_case.full_signature: @Test public void testNoTargetLabelsPresent()
test_case.identifier: testNoTargetLabelsPresent
test_case.invocations: getTopologyTemplate getElement collect map filter stream getTopLevelNTs isPresent getTargetLabel toList allocate assertEquals size getTopology get getTopology get assertEquals size getNodeTemplateOrRelationshipTemplate assertEquals size getNodeTemplateOrRelationshipTemplate getNodeTemplates add getLocalPart getType assertEquals size assertEquals count filter stream equalsIgnoreCase assertEquals count filter stream equalsIgnoreCase getTopLevelNTs get contains getId assertEquals getLocalPart getType getHostedOnSuccessor get getNodeTemplates add getLocalPart getType assertEquals size assertEquals count filter stream equalsIgnoreCase assertEquals count filter stream equalsIgnoreCase getTopLevelNTs get contains getId assertEquals getLocalPart getType getHostedOnSuccessor get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testNoTargetLabelsPresent()
focal_class.file: org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/targetallocation/criteria/minhosts/MinHosts.java
focal_class.identifier: MinHosts
focal_class.class_method_signature: MinHosts.MinHosts(JsonNode params, int outputCap)
focal_class.full_signature: public  MinHosts(JsonNode params, int outputCap)
focal_class.identifier: MinHosts
focal_class.modifiers: public
focal_class.parameters: (JsonNode params, int outputCap)
focal_class.signature:  MinHosts(JsonNode params, int outputCap)
focal_class.class_method_signature: MinHosts.filter(List<TopologyWrapper> topologies)
focal_class.full_signature: @Override public List<TopologyWrapper> filter(List<TopologyWrapper> topologies)
focal_class.identifier: filter
focal_class.modifiers: @Override public
focal_class.parameters: (List<TopologyWrapper> topologies)
focal_class.return: List<TopologyWrapper>
focal_class.signature: List<TopologyWrapper> filter(List<TopologyWrapper> topologies)
focal_class.class_method_signature: MinHosts.generateTargetLabelTopologies(TopologyWrapper topology)
focal_class.full_signature: @Override public List<TopologyWrapper> generateTargetLabelTopologies(TopologyWrapper topology)
focal_class.identifier: generateTargetLabelTopologies
focal_class.modifiers: @Override public
focal_class.parameters: (TopologyWrapper topology)
focal_class.return: List<TopologyWrapper>
focal_class.signature: List<TopologyWrapper> generateTargetLabelTopologies(TopologyWrapper topology)
focal_class.class_method_signature: MinHosts.getPossibleMatches(TopologyWrapper topology)
focal_class.full_signature: @Override protected List<List<PermutationHelper>> getPossibleMatches(TopologyWrapper topology)
focal_class.identifier: getPossibleMatches
focal_class.modifiers: @Override protected
focal_class.parameters: (TopologyWrapper topology)
focal_class.return: List<List<PermutationHelper>>
focal_class.signature: List<List<PermutationHelper>> getPossibleMatches(TopologyWrapper topology)
focal_class.class_method_signature: MinHosts.getPermutations(List<List<PermutationHelper>> possibilities)
focal_class.full_signature: @Override protected List<List<PermutationHelper>> getPermutations(List<List<PermutationHelper>> possibilities)
focal_class.identifier: getPermutations
focal_class.modifiers: @Override protected
focal_class.parameters: (List<List<PermutationHelper>> possibilities)
focal_class.return: List<List<PermutationHelper>>
focal_class.signature: List<List<PermutationHelper>> getPermutations(List<List<PermutationHelper>> possibilities)
focal_class.class_method_signature: MinHosts.toPermutationHelpers(Map<TNodeTemplate, List<TTopologyTemplate>> possibleReplacements)
focal_class.full_signature: private List<List<PermutationHelper>> toPermutationHelpers(Map<TNodeTemplate, List<TTopologyTemplate>> possibleReplacements)
focal_class.identifier: toPermutationHelpers
focal_class.modifiers: private
focal_class.parameters: (Map<TNodeTemplate, List<TTopologyTemplate>> possibleReplacements)
focal_class.return: List<List<PermutationHelper>>
focal_class.signature: List<List<PermutationHelper>> toPermutationHelpers(Map<TNodeTemplate, List<TTopologyTemplate>> possibleReplacements)
focal_class.class_method_signature: MinHosts.toInjectParameter(TopologyWrapper topology, List<PermutationHelper> permutation)
focal_class.full_signature: @Override protected Map<String, TTopologyTemplate> toInjectParameter(TopologyWrapper topology, List<PermutationHelper> permutation)
focal_class.identifier: toInjectParameter
focal_class.modifiers: @Override protected
focal_class.parameters: (TopologyWrapper topology, List<PermutationHelper> permutation)
focal_class.return: Map<String, TTopologyTemplate>
focal_class.signature: Map<String, TTopologyTemplate> toInjectParameter(TopologyWrapper topology, List<PermutationHelper> permutation)
focal_class.superclass: extends CriteriaCommon
focal_method.body: @Override
      public List<TopologyWrapper> filter(List<TopologyWrapper> topologies) {
          int minCount = Collections.min(topologies, Comparator.comparingInt(t -> t.getNodeTemplates().size()))
              .getNodeTemplates().size();
          return topologies.stream().filter(t -> t.getNodeTemplates().size() == minCount).collect(Collectors.toList());
      }
focal_method.class_method_signature: MinHosts.filter(List<TopologyWrapper> topologies)
focal_method.full_signature: @Override public List<TopologyWrapper> filter(List<TopologyWrapper> topologies)
focal_method.identifier: filter
focal_method.invocations: size getNodeTemplates min comparingInt size getNodeTemplates collect filter stream size getNodeTemplates toList
focal_method.modifiers: @Override public
focal_method.parameters: (List<TopologyWrapper> topologies)
focal_method.return: List<TopologyWrapper>
focal_method.signature: List<TopologyWrapper> filter(List<TopologyWrapper> topologies)