Search in sources :

Example 51 with JSONObject

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

the class OfflineConverter method toJSON.

@Override
public JSONObject toJSON(Offline o) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    c.put("node", JSONs.elementToJSON(o.getInvolvedNodes().iterator().next()));
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 52 with JSONObject

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

the class QuarantineConverter method toJSON.

@Override
public JSONObject toJSON(Quarantine o) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    c.put("node", JSONs.elementToJSON(o.getInvolvedNodes().iterator().next()));
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 53 with JSONObject

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

the class ResourceCapacityConverter method toJSON.

@Override
public JSONObject toJSON(ResourceCapacity o) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    c.put("nodes", nodesToJSON(o.getInvolvedNodes()));
    c.put("rc", o.getResource());
    c.put("amount", o.getAmount());
    c.put("continuous", o.isContinuous());
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 54 with JSONObject

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

the class RunningCapacityConverter method toJSON.

@Override
public JSONObject toJSON(RunningCapacity o) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    c.put("nodes", nodesToJSON(o.getInvolvedNodes()));
    c.put("amount", o.getAmount());
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 55 with JSONObject

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

the class ConstraintsConverter method fromJSON.

/**
 * Convert a json-encoded constraint.
 *
 * @param mo the model to rely on
 * @param in the constraint to decode
 * @return the resulting constraint
 * @throws JSONConverterException if the conversion failed
 */
public Constraint fromJSON(Model mo, JSONObject in) throws JSONConverterException {
    checkKeys(in, "id");
    Object id = in.get("id");
    ConstraintConverter<? extends Constraint> c = json2java.get(id.toString());
    if (c == null) {
        throw new JSONConverterException("No converter available for a constraint having id '" + id + "'");
    }
    return c.fromJSON(mo, in);
}
Also used : JSONObject(net.minidev.json.JSONObject) JSONConverterException(org.btrplace.json.JSONConverterException)

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