Search in sources :

Example 56 with JSONObject

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

the class LonelyConverter method toJSON.

@Override
public JSONObject toJSON(Lonely o) {
    JSONObject c = new JSONObject();
    c.put("id", getJSONId());
    c.put("vms", vmsToJSON(o.getInvolvedVMs()));
    c.put("continuous", o.isContinuous());
    return c;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 57 with JSONObject

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

the class NoDelayConverter method toJSON.

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

Example 58 with JSONObject

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

the class OnlineConverter method toJSON.

@Override
public JSONObject toJSON(Online 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 59 with JSONObject

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

the class ModelConverterTest method testCompleteMapping.

@Test
public void testCompleteMapping() throws JSONConverterException {
    Model mo = new DefaultModel();
    Mapping c = mo.getMapping();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    c.addOnlineNode(n1);
    c.addOfflineNode(n2);
    c.addRunningVM(vm1, n1);
    c.addSleepingVM(vm2, n1);
    c.addReadyVM(vm3);
    c.addOnlineNode(n3);
    c.addRunningVM(vm4, n3);
    ModelConverter conv = new ModelConverter();
    JSONObject o = conv.toJSON(mo);
    System.out.println(o);
    Assert.assertEquals(conv.fromJSON(o), mo);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) JSONObject(net.minidev.json.JSONObject) Node(org.btrplace.model.Node) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Mapping(org.btrplace.model.Mapping) Test(org.testng.annotations.Test)

Example 60 with JSONObject

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

the class ConstraintsConverterTest method testFromJSONWithoutID.

@Test(dependsOnMethods = { "testRegister" }, expectedExceptions = { JSONConverterException.class })
public void testFromJSONWithoutID() throws JSONConverterException {
    JSONObject ob = new JSONObject();
    ob.put("value", "val");
    ConstraintsConverter c = new ConstraintsConverter();
    c.register(new MockConstraintConverter());
    c.fromJSON(null, ob);
}
Also used : JSONObject(net.minidev.json.JSONObject) 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