/** Test spread({}). must fail (empty set) */ @Test(expectedExceptions = {ConstraintBuilderException.class}) public void testWithEmptySet() throws ConstraintBuilderException { ContinuousSpreadBuilder mb = new ContinuousSpreadBuilder(); List<VJobElement> params = new LinkedList<VJobElement>(); ExplodedSet s1 = new ExplodedSet(); params.add(s1); mb.buildConstraint(params); }
/** Test spread({vm1}, {vm2}). must fail: 2 params */ @Test(expectedExceptions = {ConstraintBuilderException.class}) public void testWithBadParamsNumber() throws ConstraintBuilderException { ContinuousSpreadBuilder mb = new ContinuousSpreadBuilder(); List<VJobElement> params = new LinkedList<VJobElement>(); ExplodedSet<DefaultVirtualMachine> s1 = new ExplodedSet<DefaultVirtualMachine>(); s1.add(new DefaultVirtualMachine("vm1", 1, 1, 1)); ExplodedSet<DefaultVirtualMachine> s2 = new ExplodedSet<DefaultVirtualMachine>(); s2.add(new DefaultVirtualMachine("vm2", 1, 1, 1)); params.add(s1); params.add(s2); mb.buildConstraint(params); }
/** Test cSpread({vm1,vm2,vm3}) */ public void testValid() { ContinuousSpreadBuilder mb = new ContinuousSpreadBuilder(); List<VJobElement> params = new LinkedList<VJobElement>(); ExplodedSet<DefaultVirtualMachine> s1 = new ExplodedSet<DefaultVirtualMachine>(); s1.add(new DefaultVirtualMachine("vm1", 1, 1, 1)); s1.add(new DefaultVirtualMachine("vm2", 1, 1, 1)); s1.add(new DefaultVirtualMachine("vm3", 1, 1, 1)); params.add(s1); try { ContinuousSpread sc = mb.buildConstraint(params); Assert.assertEquals(sc.getAllVirtualMachines().size(), 3); Assert.assertEquals(sc.getVirtualMachines(), s1); } catch (ConstraintBuilderException e) { Assert.fail(e.getMessage(), e); } }