Search in sources :

Example 61 with JSONObject

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);
}
Also used : JSONObject(net.minidev.json.JSONObject) Test(org.testng.annotations.Test)

Example 62 with JSONObject

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;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 63 with JSONObject

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;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 64 with JSONObject

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);
}
Also used : VM(org.btrplace.model.VM) JSONs.getVM(org.btrplace.json.JSONs.getVM) ArrayList(java.util.ArrayList) JSONArray(net.minidev.json.JSONArray) JSONObject(net.minidev.json.JSONObject) Seq(org.btrplace.model.constraint.Seq)

Example 65 with JSONObject

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;
}
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