Search in sources :

Example 76 with JSONObject

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

the class NetworkConverter method toJSON.

@Override
public JSONObject toJSON(Network net) throws JSONConverterException {
    JSONObject container = new JSONObject();
    container.put(ModelViewConverter.IDENTIFIER, getJSONId());
    container.put("switches", switchesToJSON(net.getSwitches()));
    container.put("links", linksToJSON(net.getLinks()));
    container.put("routing", routingToJSON(net.getRouting()));
    return container;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 77 with JSONObject

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

the class StaticRoutingConverter method nodesMapToJSON.

/**
 * Convert a nodes map (a pair of two distinguishable nodes to source and destination) into a JSON object
 *
 * @param nm the nodes map to convert
 * @return the nodes map JSON object
 */
public JSONObject nodesMapToJSON(StaticRouting.NodesMap nm) {
    JSONObject o = new JSONObject();
    o.put("src", nm.getSrc().id());
    o.put("dst", nm.getDst().id());
    return o;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 78 with JSONObject

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

the class DeadlineConverter method toJSON.

@Override
public JSONObject toJSON(Deadline deadline) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    c.put("vm", JSONs.elementToJSON(deadline.getInvolvedVMs().iterator().next()));
    c.put("timestamp", deadline.getTimestamp());
    c.put("continuous", deadline.isContinuous());
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 79 with JSONObject

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

the class PrecedenceConverter method toJSON.

@Override
public JSONObject toJSON(Precedence precedence) {
    JSONObject c = new JSONObject();
    Iterator<VM> it = precedence.getInvolvedVMs().iterator();
    c.put("id", getJSONId());
    c.put("vm1", JSONs.elementToJSON(it.next()));
    c.put("vm2", JSONs.elementToJSON(it.next()));
    c.put("continuous", precedence.isContinuous());
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject) JSONs.requiredVM(org.btrplace.json.JSONs.requiredVM) VM(org.btrplace.model.VM)

Example 80 with JSONObject

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

the class NamingServiceConverterTest method test.

@Test
public void test() throws JSONConverterException {
    NamingService<VM> ns = NamingService.newVMNS();
    Model mo = new DefaultModel();
    for (int i = 0; i < 10; i++) {
        VM v = mo.newVM();
        ns.register(v, "VM " + i);
    }
    NamingServiceConverter nsc = new NamingServiceConverter();
    JSONObject o = nsc.toJSON(ns);
    System.out.println(o);
    @SuppressWarnings("unchecked") NamingService<VM> ns2 = (NamingService<VM>) nsc.fromJSON(mo, o);
    Assert.assertEquals(ns, ns2);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) JSONObject(net.minidev.json.JSONObject) NamingService(org.btrplace.model.view.NamingService) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

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