Search in sources :

Example 81 with JSONObject

use of net.minidev.json.JSONObject in project scheduler by btrplace.

the class TestCase method toJSON.

public String toJSON() throws JSONConverterException {
    InstanceConverter ic = new InstanceConverter();
    ic.getConstraintsConverter().register(new ScheduleConverter());
    ReconfigurationPlanConverter pc = new ReconfigurationPlanConverter();
    JSONObject o = new JSONObject();
    o.put("constraint", constraint().id());
    JSONArray a = new JSONArray();
    for (Constant c : args()) {
        a.add(c.toJSON());
    }
    o.put("args", a);
    o.put("continuous", continuous());
    o.put("groups", groups());
    o.put("plan", pc.toJSON(plan()));
    o.put("instance", ic.toJSON(instance()));
    return o.toJSONString();
}
Also used : ScheduleConverter(org.btrplace.safeplace.testing.verification.btrplace.ScheduleConverter) JSONObject(net.minidev.json.JSONObject) Constant(org.btrplace.safeplace.spec.term.Constant) InstanceConverter(org.btrplace.json.model.InstanceConverter) ReconfigurationPlanConverter(org.btrplace.json.plan.ReconfigurationPlanConverter) JSONArray(net.minidev.json.JSONArray)

Example 82 with JSONObject

use of net.minidev.json.JSONObject in project scheduler by btrplace.

the class ModelViewsConverterTest method testFromJSonWithNoConverter.

@Test(dependsOnMethods = { "testRegister" }, expectedExceptions = { JSONConverterException.class })
public void testFromJSonWithNoConverter() throws JSONConverterException {
    JSONObject ob = new JSONObject();
    ob.put("id", "mockView");
    ob.put("value", "val");
    ModelViewsConverter c = new ModelViewsConverter();
    c.fromJSON(null, ob);
}
Also used : JSONObject(net.minidev.json.JSONObject) Test(org.testng.annotations.Test)

Example 83 with JSONObject

use of net.minidev.json.JSONObject in project scheduler by btrplace.

the class ModelViewsConverterTest method testWithExistingConverter.

@Test(dependsOnMethods = { "testRegister" })
public void testWithExistingConverter() throws JSONConverterException {
    ModelViewsConverter c = new ModelViewsConverter();
    c.register(new MockModelViewConverter());
    MockModelView m = new MockModelView("bar");
    JSONObject o = c.toJSON(m);
    MockModelView m2 = (MockModelView) c.fromJSON(null, o);
    Assert.assertEquals(m.value, m2.value);
}
Also used : JSONObject(net.minidev.json.JSONObject) Test(org.testng.annotations.Test)

Example 84 with JSONObject

use of net.minidev.json.JSONObject in project scheduler by btrplace.

the class Constant method fromJSON.

public static Constant fromJSON(JSONObject o) {
    Type t = Type.decode(o.getAsString("type"));
    Object r = t.fromJSON(o.get("value"));
    return new Constant(r, t);
}
Also used : Type(org.btrplace.safeplace.spec.type.Type) JSONObject(net.minidev.json.JSONObject)

Example 85 with JSONObject

use of net.minidev.json.JSONObject in project scheduler by btrplace.

the class ScheduleConverter method toJSON.

@Override
public JSONObject toJSON(Schedule o) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    if (o.getNode() != null) {
        c.put("node", JSONs.elementToJSON(o.getNode()));
    } else {
        c.put("vm", JSONs.elementToJSON(o.getVM()));
    }
    c.put("start", o.getStart());
    c.put("END", o.getEnd());
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Aggregations

JSONObject (net.minidev.json.JSONObject)257 JSONArray (net.minidev.json.JSONArray)51 Test (org.junit.Test)39 Test (org.testng.annotations.Test)38 JSONParser (net.minidev.json.parser.JSONParser)26 HashMap (java.util.HashMap)22 MockFlowFile (org.apache.nifi.util.MockFlowFile)16 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)14 ParseException (net.minidev.json.parser.ParseException)14 Test (org.junit.jupiter.api.Test)14 Map (java.util.Map)13 JSONConverterException (org.btrplace.json.JSONConverterException)13 SignedJWT (com.nimbusds.jwt.SignedJWT)12 Node (org.btrplace.model.Node)12 VM (org.btrplace.model.VM)12 JWSHeader (com.nimbusds.jose.JWSHeader)10 RSASSASigner (com.nimbusds.jose.crypto.RSASSASigner)10 ArrayList (java.util.ArrayList)10 AuthenticationContext (org.wso2.carbon.apimgt.gateway.handlers.security.AuthenticationContext)10 OpenAPI (io.swagger.v3.oas.models.OpenAPI)9