use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class ConstraintsConverterTest method testWithExistingConverter.
@Test(dependsOnMethods = { "testRegister" })
public void testWithExistingConverter() throws JSONConverterException {
ConstraintsConverter c = new ConstraintsConverter();
c.register(new MockConstraintConverter());
MockSatConstraint m = new MockSatConstraint("bar");
JSONObject o = c.toJSON(m);
MockSatConstraint m2 = (MockSatConstraint) c.fromJSON(null, o);
Assert.assertEquals(m.str, m2.str);
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class EventConverter method toJSON.
/**
* Create a JSON from an event.
* First, a skeleton is created to mention the event identifier,
* Second, {@link #fillJSON} is called.
*
* @param ev the event to convert.
* @return the resulting JSON message.
*/
default JSONObject toJSON(final E ev) {
final JSONObject ob = new JSONObject();
ob.put(ActionConverter.ID_LABEL, id());
fillJSON(ev, ob);
return ob;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class RunningConverter method toJSON.
@Override
public JSONObject toJSON(Running o) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
c.put("vm", JSONs.elementToJSON(o.getInvolvedVMs().iterator().next()));
return c;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class SeqConverter method fromJSON.
@Override
public Seq fromJSON(Model mo, JSONObject o) throws JSONConverterException {
checkId(o);
List<VM> s = new ArrayList<>();
for (Object ob : (JSONArray) o.get("vms")) {
s.add(getVM(mo, (Integer) ob));
}
return new Seq(s);
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class SeqConverter method toJSON.
@Override
public JSONObject toJSON(Seq o) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
c.put("vms", vmsToJSON(o.getInvolvedVMs()));
return c;
}
Aggregations