use of org.btrplace.plan.event.Action in project scheduler by btrplace.
the class ActionTest method testEvents.
@Test
public void testEvents() {
Action a1 = new MockAction(new VM(1), 1, 3);
Event e = mock(Event.class);
a1.addEvent(Action.Hook.PRE, e);
Assert.assertEquals(1, a1.getEvents(Action.Hook.PRE).size());
a1.addEvent(Action.Hook.POST, e);
Assert.assertEquals(1, a1.getEvents(Action.Hook.POST).size());
}
use of org.btrplace.plan.event.Action in project scheduler by btrplace.
the class ContinuousViolationExceptionTest method test.
@Test
public void test() {
SatConstraint c = Mockito.mock(SatConstraint.class);
Action a = Mockito.mock(Action.class);
ContinuousViolationException ex = new ContinuousViolationException(c, a);
Assert.assertEquals(ex.getAction(), a);
Assert.assertEquals(ex.getConstraint(), c);
Assert.assertFalse(ex.toString().contains("null"));
}
use of org.btrplace.plan.event.Action in project scheduler by btrplace.
the class DefaultReconfigurationPlanTest method testAddDurationAndSize.
@Test(dependsOnMethods = { "testInstantiate" })
public void testAddDurationAndSize() {
Model m = new DefaultModel();
List<VM> vms = Util.newVMs(m, 10);
DefaultReconfigurationPlan p = new DefaultReconfigurationPlan(m);
Action a1 = new MockAction(vms.get(0), 1, 3);
Action a2 = new MockAction(vms.get(1), 2, 4);
Action a3 = new MockAction(vms.get(2), 2, 4);
Action a4 = new MockAction(vms.get(3), 1, 3);
Assert.assertTrue(p.add(a1));
Assert.assertEquals(3, p.getDuration());
Assert.assertTrue(p.add(a4));
Assert.assertTrue(p.add(a3));
Assert.assertTrue(p.add(a2));
Assert.assertEquals(4, p.getDuration());
int last = -1;
System.out.println(p);
for (Action a : p) {
Assert.assertTrue(a.getStart() >= last);
last = a.getStart();
}
Assert.assertFalse(p.add(a2));
Assert.assertEquals(4, p.getSize());
Assert.assertFalse(p.toString().contains("null"));
}
use of org.btrplace.plan.event.Action in project scheduler by btrplace.
the class TimedBasedActionComparatorTest method testEqualityWithSimultaneousDisallowed.
@Test
public void testEqualityWithSimultaneousDisallowed() {
VM vm2 = mo.newVM();
Action a = new MockAction(vm, 0, 4);
Action b = new MockAction(vm2, 0, 4);
Assert.assertNotEquals(new TimedBasedActionComparator(false, true).compare(a, b), 0);
Assert.assertNotEquals(new TimedBasedActionComparator(true, true).compare(a, b), 0);
}
use of org.btrplace.plan.event.Action in project scheduler by btrplace.
the class TimedBasedActionComparatorTest method testEquality.
@Test
public void testEquality() {
Action a = new MockAction(vm, 0, 4);
Action b = new MockAction(vm, 0, 4);
Assert.assertEquals(startCmp.compare(a, b), 0);
Assert.assertEquals(stopCmp.compare(a, b), 0);
}
Aggregations