use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class LonelyConverter method toJSON.
@Override
public JSONObject toJSON(Lonely o) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
c.put("vms", vmsToJSON(o.getInvolvedVMs()));
c.put("continuous", o.isContinuous());
return c;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class NoDelayConverter method toJSON.
@Override
public JSONObject toJSON(NoDelay noDelay) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
c.put("vm", JSONs.elementToJSON(noDelay.getInvolvedVMs().iterator().next()));
c.put("continuous", noDelay.isContinuous());
return c;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class OnlineConverter method toJSON.
@Override
public JSONObject toJSON(Online o) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
c.put("node", JSONs.elementToJSON(o.getInvolvedNodes().iterator().next()));
return c;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class ModelConverterTest method testCompleteMapping.
@Test
public void testCompleteMapping() throws JSONConverterException {
Model mo = new DefaultModel();
Mapping c = mo.getMapping();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
c.addOnlineNode(n1);
c.addOfflineNode(n2);
c.addRunningVM(vm1, n1);
c.addSleepingVM(vm2, n1);
c.addReadyVM(vm3);
c.addOnlineNode(n3);
c.addRunningVM(vm4, n3);
ModelConverter conv = new ModelConverter();
JSONObject o = conv.toJSON(mo);
System.out.println(o);
Assert.assertEquals(conv.fromJSON(o), mo);
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class ConstraintsConverterTest method testFromJSONWithoutID.
@Test(dependsOnMethods = { "testRegister" }, expectedExceptions = { JSONConverterException.class })
public void testFromJSONWithoutID() throws JSONConverterException {
JSONObject ob = new JSONObject();
ob.put("value", "val");
ConstraintsConverter c = new ConstraintsConverter();
c.register(new MockConstraintConverter());
c.fromJSON(null, ob);
}
Aggregations