use of org.btrplace.model.Model in project scheduler by btrplace.
the class FenceTest method testInstantiation.
@Test
public void testInstantiation() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
Set<Node> nodes = new HashSet<>(Collections.singletonList(ns.get(0)));
Fence f = new Fence(vms.get(0), nodes);
Assert.assertNotNull(f.getChecker());
Assert.assertEquals(vms.get(0), f.getInvolvedVMs().iterator().next());
Assert.assertEquals(nodes, f.getInvolvedNodes());
Assert.assertFalse(f.toString().contains("null"));
Assert.assertFalse(f.isContinuous());
Assert.assertTrue(f.setContinuous(true));
System.out.println(f);
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class FenceTest method testFences.
@Test
public void testFences() {
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 5);
List<Node> ns = Util.newNodes(mo, 5);
List<Fence> c = Fence.newFence(vms, ns);
Assert.assertEquals(vms.size(), c.size());
c.stream().forEach((q) -> {
Assert.assertTrue(vms.containsAll(q.getInvolvedVMs()));
Assert.assertEquals(ns, q.getInvolvedNodes());
Assert.assertFalse(q.isContinuous());
});
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class KilledTest method testEquals.
@Test
public void testEquals() {
Model mo = new DefaultModel();
VM v = mo.newVM();
Killed s = new Killed(v);
Assert.assertTrue(s.equals(s));
Assert.assertTrue(new Killed(v).equals(s));
Assert.assertEquals(new Killed(v).hashCode(), s.hashCode());
Assert.assertFalse(new Killed(mo.newVM()).equals(s));
Assert.assertFalse(new Killed(mo.newVM()).equals(new Object()));
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class MaxOnlineTest method testInstantiation.
@Test
public void testInstantiation() {
Model mo = new DefaultModel();
Set<Node> s = new HashSet<>(Arrays.asList(mo.newNode(), mo.newNode()));
MaxOnline o = new MaxOnline(s, 3);
Assert.assertNotNull(o.getChecker());
Assert.assertEquals(o.getInvolvedNodes(), s);
Assert.assertTrue(o.getInvolvedVMs().isEmpty());
Assert.assertNotNull(o.toString());
Assert.assertFalse(o.isContinuous());
Assert.assertTrue(o.setContinuous(true));
Assert.assertTrue(o.isContinuous());
Assert.assertTrue(o.setContinuous(false));
Assert.assertTrue(o.equals(new MaxOnline(s, 3)));
Assert.assertEquals(o.hashCode(), new MaxOnline(s, 3, false).hashCode());
Assert.assertFalse(o.equals(new MaxOnline(s, 4)));
Assert.assertFalse(o.equals(new MaxOnline(Collections.singleton(mo.newNode()), 3)));
Assert.assertFalse(o.equals(new MaxOnline(s, 3, true)));
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class OverbookTest method testEquals.
@Test
public void testEquals() {
Model mo = new DefaultModel();
Node n = mo.newNode();
Overbook s = new Overbook(n, "foo", 3);
Assert.assertTrue(s.equals(s));
Overbook o2 = new Overbook(n, "foo", 3);
Assert.assertTrue(o2.equals(s));
Assert.assertEquals(o2.hashCode(), s.hashCode());
Assert.assertFalse(new Overbook(n, "bar", 3).equals(s));
Assert.assertFalse(new Overbook(n, "foo", 2).equals(s));
Assert.assertFalse(new Overbook(mo.newNode(), "foo", 3).equals(s));
Assert.assertNotEquals(new Overbook(mo.newNode(), "foo", 3, true), new Overbook(mo.newNode(), "foo", 3, false));
Assert.assertNotEquals(new Overbook(mo.newNode(), "foo", 3, true).hashCode(), new Overbook(mo.newNode(), "foo", 3, false).hashCode());
}
Aggregations