@Test
public void twoTargetLabelsOnePossibleResult() {

    ServiceTemplateId id = new ServiceTemplateId("http://www.winery.opentosca.org/test/targetallocation/servicetemplates",
        "MinExternalConnectionsTest1", false);
    TopologyWrapper topology = new TopologyWrapper(repository.getElement(id).getTopologyTemplate());
    ConnectsToGraph connectsToGraph = new ConnectsToGraph(topology);
    KargerMinCutVariation kargerMinCutVariation = new KargerMinCutVariation(connectsToGraph);
    List<ConnectsToGraph> results = new ArrayList<>(kargerMinCutVariation.computeTargetLabelPartitions());
    // testing a monte carlo algorithm doesn't always work
    if (results.size() != 1 || results.get(0).getEdges().size() != 1) {
        LOGGER.debug("Monte Carlo Algorithm produced wrong result");
        return;
    }
    assertEquals(results.size(), 1);
    ConnectsToGraph result = results.get(0);
    assertEquals(result.getEdges().size(), 1);
    assertEquals(result.getNodes().size(), 2);
    Set<String> pastureProvider = new HashSet<>(Collections.singletonList("shetland_pony"));
    Set<String> fieldProvider = new HashSet<>(Arrays.asList("shetland_pony_2", "shetland_pony_3", "shetland_pony_4"));
    ConnectsToGraph.Node pastureNode = result.getNodes().stream()
        .filter(node -> node.getTargetLabel().equalsIgnoreCase("PastureProvider")).collect(Collectors.toList()).get(0);
    ConnectsToGraph.Node fieldNode = result.getNodes().stream()
        .filter(node -> node.getTargetLabel().equalsIgnoreCase("FieldProvider")).collect(Collectors.toList()).get(0);
    assertEquals(pastureNode.getNodeTemplateIds(), pastureProvider);
    assertEquals(fieldNode.getNodeTemplateIds(), fieldProvider);
}