Search in sources :

Example 46 with JSONObject

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

the class JSONs method requiredString.

/**
 * Read an expected string.
 *
 * @param o  the object to parse
 * @param id the key in the map that points to the string
 * @return the string
 * @throws JSONConverterException if the key does not point to a string
 */
public static String requiredString(JSONObject o, String id) throws JSONConverterException {
    checkKeys(o, id);
    Object x = o.get(id);
    return x.toString();
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 47 with JSONObject

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

the class JSONs method requiredNodePart.

/**
 * Read partitions of nodes.
 *
 * @param mo the associated model to browse
 * @param o  the object to parse
 * @param id the key in the map that points to the partitions
 * @return the parsed partition
 * @throws JSONConverterException if the key does not point to partitions of nodes
 */
public static Set<Collection<Node>> requiredNodePart(Model mo, JSONObject o, String id) throws JSONConverterException {
    Set<Collection<Node>> nodes = new HashSet<>();
    Object x = o.get(id);
    if (!(x instanceof JSONArray)) {
        throw new JSONConverterException("Set of identifiers sets expected at key '" + id + "'");
    }
    for (Object obj : (JSONArray) x) {
        nodes.add(nodesFromJSON(mo, (JSONArray) obj));
    }
    return nodes;
}
Also used : JSONArray(net.minidev.json.JSONArray) Collection(java.util.Collection) JSONObject(net.minidev.json.JSONObject) HashSet(java.util.HashSet)

Example 48 with JSONObject

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

the class InstanceConverter method toJSON.

@Override
public JSONObject toJSON(Instance instance) throws JSONConverterException {
    JSONObject ob = new JSONObject();
    ob.put(MODEL_LABEL, moc.toJSON(instance.getModel()));
    ob.put(CONSTRAINTS_LABEL, cc.toJSON(instance.getSatConstraints()));
    ob.put(OBJ_LABEL, cc.toJSON(instance.getOptConstraint()));
    return ob;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 49 with JSONObject

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

the class KilledConverter method toJSON.

@Override
public JSONObject toJSON(Killed 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 50 with JSONObject

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

the class MinMigrationsConverter method toJSON.

@Override
public JSONObject toJSON(MinMigrations o) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    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