@Test
public void filter() throws Exception {

    ServiceTemplateId id = new ServiceTemplateId("http://www.winery.opentosca.org/test/targetallocation/servicetemplates",
        "MinExternalConnectionsTest1", false);
    TTopologyTemplate twoExternal = repository.getElement(id).getTopologyTemplate();
    ModelUtilities.setTargetLabel(twoExternal.getNodeTemplate("shetland_pony_2"), "PastureProvider");
    ModelUtilities.setTargetLabel(twoExternal.getNodeTemplate("shetland_pony_3"), "PastureProvider");
    TTopologyTemplate oneExternal = AllocationUtils.deepcopy(twoExternal);
    ModelUtilities.setTargetLabel(oneExternal.getNodeTemplate("shetland_pony_2"), "FieldProvider");
    ModelUtilities.setTargetLabel(oneExternal.getNodeTemplate("shetland_pony_3"), "FieldProvider");
    List<TopologyWrapper> topologies = new ArrayList<>();
    topologies.add(new TopologyWrapper(twoExternal));
    topologies.add(new TopologyWrapper(oneExternal));
    Criteria minExternalConnections = new MinExternalConnections(null, Integer.MAX_VALUE);
    List<TopologyWrapper> filtered = minExternalConnections.filter(topologies);
    assertEquals(1, filtered.size());
    TTopologyTemplate result = filtered.get(0).getTopology();
    assertEquals("PastureProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony")).get());
    assertEquals("FieldProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony_2")).get());
    assertEquals("FieldProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony_3")).get());
    assertEquals("FieldProvider".toLowerCase(), ModelUtilities.getTargetLabel(result.getNodeTemplate("shetland_pony_4")).get());
}