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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations