use of org.btrplace.model.view.ModelView in project scheduler by btrplace.
the class SubstitutedVMEventTest method testApply.
@Test
public void testApply() {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addReadyVM(vms.get(0));
map.addReadyVM(vms.get(2));
ModelView v = mock(ModelView.class);
mo.attach(v);
Assert.assertTrue(s.apply(mo));
verify(v).substituteVM(vms.get(0), vms.get(1));
}
use of org.btrplace.model.view.ModelView in project scheduler by btrplace.
the class DefaultModel method toString.
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append("Mapping:\n");
b.append(getMapping());
b.append("\nAttributes:");
if (!getAttributes().getDefined().isEmpty()) {
b.append("\n");
b.append(getAttributes());
} else {
b.append(" -");
}
b.append("\nViews:");
if (resources.isEmpty()) {
b.append(" -");
} else {
b.append("\n");
StringJoiner joiner = new StringJoiner("\n");
for (Map.Entry<String, ModelView> entry : resources.entrySet()) {
joiner.add(String.format("%s: %s", entry.getKey(), entry.getValue()));
}
b.append(joiner.toString());
}
return b.toString();
}
use of org.btrplace.model.view.ModelView in project scheduler by btrplace.
the class DefaultModel method copy.
@Override
public Model copy() {
DefaultModel m = new DefaultModel(elemBuilder.copy());
MappingUtils.fill(cfg, m.cfg);
for (ModelView rc : resources.values()) {
m.attach(rc.copy());
}
m.setAttributes(this.getAttributes().copy());
return m;
}
use of org.btrplace.model.view.ModelView in project scheduler by btrplace.
the class DefaultModelTest method testDetachView.
@Test(dependsOnMethods = { "testAttachView", "testInstantiate" })
public void testDetachView() {
Model i = new DefaultModel();
ModelView v = mock(ModelView.class);
when(v.getIdentifier()).thenReturn("cpu");
i.attach(v);
Assert.assertTrue(i.detach(v));
Assert.assertTrue(i.getViews().isEmpty());
Assert.assertNull(i.getView("cpu"));
Assert.assertFalse(i.detach(v));
}
use of org.btrplace.model.view.ModelView in project scheduler by btrplace.
the class DefaultModelTest method testClearViews.
@Test(dependsOnMethods = { "testAttachView", "testInstantiate" })
public void testClearViews() {
Model i = new DefaultModel();
ModelView v1 = mock(ModelView.class);
when(v1.getIdentifier()).thenReturn("cpu");
ModelView v2 = mock(ModelView.class);
when(v2.getIdentifier()).thenReturn("mem");
i.attach(v1);
i.attach(v2);
i.clearViews();
Assert.assertTrue(i.getViews().isEmpty());
}
Aggregations