Search in sources :

Example 6 with JSONObject

use of net.minidev.json.JSONObject in project nifi by apache.

the class ITPutRethinkDBTest method testValidSingleMessage.

@Test
public void testValidSingleMessage() {
    runner.assertValid();
    RethinkDB.r.db(dbName).table(table).delete().run(connection);
    long count = RethinkDB.r.db(dbName).table(table).count().run(connection);
    assertEquals("Count should be same", 0L, count);
    JSONObject message = new JSONObject();
    message.put("hello", "rethinkdb");
    byte[] bytes = message.toJSONString().getBytes();
    runner.enqueue(bytes);
    runner.run(1, true, true);
    runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_SUCCESS, 1);
    List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(PutRethinkDB.REL_SUCCESS);
    assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY), "0");
    assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY), "0");
    assertNotNull(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY));
    assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY), "1");
    assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY), "0");
    assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY), "0");
    assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY), "0");
    assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY), "null");
    count = RethinkDB.r.db(dbName).table(table).count().run(connection);
    assertEquals("Count should be same", 1L, count);
}
Also used : MockFlowFile(org.apache.nifi.util.MockFlowFile) JSONObject(net.minidev.json.JSONObject) Test(org.junit.Test)

Example 7 with JSONObject

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

the class ActionConverter method visit.

@Override
public Object visit(SubstitutedVMEvent a) {
    JSONObject o = new JSONObject();
    o.put(ACTION_ID_LABEL, "substitutedVM");
    o.put(VM_LABEL, elementToJSON(a.getVM()));
    o.put("newVm", elementToJSON(a.getNewVM()));
    return o;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 8 with JSONObject

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

the class ActionConverter method visit.

@Override
public JSONObject visit(ForgeVM a) {
    JSONObject o = makeActionSkeleton(a);
    o.put(ACTION_ID_LABEL, "forgeVM");
    o.put(VM_LABEL, elementToJSON(a.getVM()));
    return o;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 9 with JSONObject

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

the class ActionConverter method visit.

@Override
public JSONObject visit(BootNode a) {
    JSONObject o = makeActionSkeleton(a);
    o.put(ACTION_ID_LABEL, "bootNode");
    o.put(NODE_LABEL, elementToJSON(a.getNode()));
    return o;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Example 10 with JSONObject

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

the class ActionConverter method visit.

@Override
public JSONObject visit(SuspendVM a) {
    JSONObject o = makeActionSkeleton(a);
    o.put(ACTION_ID_LABEL, "suspendVM");
    o.put(VM_LABEL, elementToJSON(a.getVM()));
    o.put(VM_DESTINATION_LABEL, elementToJSON(a.getDestinationNode()));
    o.put(VM_LOCATION_LABEL, elementToJSON(a.getSourceNode()));
    return o;
}
Also used : JSONObject(net.minidev.json.JSONObject)

Aggregations

JSONObject (net.minidev.json.JSONObject)254 JSONArray (net.minidev.json.JSONArray)49 Test (org.junit.Test)39 Test (org.testng.annotations.Test)38 JSONParser (net.minidev.json.parser.JSONParser)23 HashMap (java.util.HashMap)22 MockFlowFile (org.apache.nifi.util.MockFlowFile)16 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)14 Test (org.junit.jupiter.api.Test)14 Map (java.util.Map)13 ParseException (net.minidev.json.parser.ParseException)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 AuthenticationContext (org.wso2.carbon.apimgt.gateway.handlers.security.AuthenticationContext)10 OpenAPI (io.swagger.v3.oas.models.OpenAPI)9 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)9