@Test public void getAllPossibleDeploymentPlans() { List<Host> hosts = new ArrayList<>(); hosts.add(new HostFake("host1", 8, 8192, 8, 0, 0, 0)); hosts.add(new HostFake("host2", 4, 4096, 4, 0, 0, 0)); hosts.add(new HostFake("host3", 2, 2048, 2, 0, 0, 0)); List<Vm> vms = new ArrayList<>(); vms.add(new Vm("vm1", "image", 1, 1024, 1, null, "")); vms.add(new Vm("vm2", "image", 4, 4096, 4, null, "")); List<DeploymentPlan> deploymentPlans = new DeploymentPlanGenerator().getPossibleDeploymentPlans(vms, hosts); assertTrue(deploymentPlans.size() == 5); for (DeploymentPlan deploymentPlan: deploymentPlans) { boolean vm1AssignedToHost2 = false; boolean vm2AssignedToHost2 = false; for (VmAssignmentToHost vmAssignmentToHost: deploymentPlan.getVmsAssignationsToHosts()) { if (vmAssignmentToHost.getVm().getName().equals("vm1") && vmAssignmentToHost.getHost().getHostname().equals("host2")) { vm1AssignedToHost2 = true; } else if (vmAssignmentToHost.getVm().getName().equals("vm2") && vmAssignmentToHost.getHost().getHostname().equals("host2")) { vm2AssignedToHost2 = true; } } assertFalse(vm1AssignedToHost2 && vm2AssignedToHost2); } }
public List<DeploymentPlan> getPossibleDeploymentPlans(List<Vm> vms, List<Host> hosts) { return DeploymentPlanFilterer.filterDeploymentPlans(getAllDeploymentPlans(vms, hosts)); }
DeploymentPlanGenerator { public List<DeploymentPlan> getPossibleDeploymentPlans(List<Vm> vms, List<Host> hosts) { return DeploymentPlanFilterer.filterDeploymentPlans(getAllDeploymentPlans(vms, hosts)); } }
DeploymentPlanGenerator { public List<DeploymentPlan> getPossibleDeploymentPlans(List<Vm> vms, List<Host> hosts) { return DeploymentPlanFilterer.filterDeploymentPlans(getAllDeploymentPlans(vms, hosts)); }  }
DeploymentPlanGenerator { public List<DeploymentPlan> getPossibleDeploymentPlans(List<Vm> vms, List<Host> hosts) { return DeploymentPlanFilterer.filterDeploymentPlans(getAllDeploymentPlans(vms, hosts)); }  List<DeploymentPlan> getPossibleDeploymentPlans(List<Vm> vms, List<Host> hosts); List<DeploymentPlan> getAllDeploymentPlans(List<Vm> vms, List<Host> hosts); List<DeploymentPlan> getDeploymentPlansWithoutRestrictions(List<Vm> vms, List<Host> hosts); }
DeploymentPlanGenerator { public List<DeploymentPlan> getPossibleDeploymentPlans(List<Vm> vms, List<Host> hosts) { return DeploymentPlanFilterer.filterDeploymentPlans(getAllDeploymentPlans(vms, hosts)); }  List<DeploymentPlan> getPossibleDeploymentPlans(List<Vm> vms, List<Host> hosts); List<DeploymentPlan> getAllDeploymentPlans(List<Vm> vms, List<Host> hosts); List<DeploymentPlan> getDeploymentPlansWithoutRestrictions(List<Vm> vms, List<Host> hosts);  }