use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class HttpCommandProcessor method response.
protected static JsonObject response(ResponseType type, String... attributes) {
JsonObject object = new JsonObject().add("status", type.toString());
if (attributes.length > 0) {
for (int i = 0; i < attributes.length; ) {
String key = attributes[i++];
String value = attributes[i++];
if (value != null) {
object.add(key, value);
}
}
}
return object;
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class SlowOperationDetector_JsonTest method testJSON_SlowEntryProcessor.
@Test
public void testJSON_SlowEntryProcessor() {
for (int i = 0; i < 2; i++) {
map.executeOnEntries(getSlowEntryProcessor(3));
}
map.executeOnEntries(getSlowEntryProcessor(4));
map.executeOnEntries(getSlowEntryProcessor(3));
awaitSlowEntryProcessors();
logger.finest(getOperationStats(instance).toString());
JsonObject firstLogJsonObject = getSlowOperationLogsJsonArray(instance).get(0).asObject();
assertJSONContainsClassName(firstLogJsonObject, "SlowEntryProcessor");
assertEqualsStringFormat("Expected %d invocations, but was %d", 4, firstLogJsonObject.get("invocations").asArray().size());
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class WanOpenSourceAntiEntropyMcEventsTest method testSyncAllREST.
@Test
public void testSyncAllREST() throws Exception {
System.setProperty(HAZELCAST_TEST_USE_NETWORK, "true");
HazelcastInstance hz = createHazelcastInstance(getConfigWithRest());
HTTPCommunicator communicator = new HTTPCommunicator(hz);
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
ManagementCenterService mcService = nodeEngine.getManagementCenterService();
List<Event> events = new LinkedList<>();
CountDownLatch latch = new CountDownLatch(1);
mcService.setEventListener(event -> {
events.add(event);
latch.countDown();
});
String jsonResult = communicator.syncMapsOverWAN(hz.getConfig().getClusterName(), "", WAN_REPLICATION_NAME, WAN_PUBLISHER_ID);
assertOpenEventually(latch);
JsonObject result = Json.parse(jsonResult).asObject();
Event event = events.get(0);
assertTrue(event instanceof WanSyncIgnoredEvent);
WanSyncIgnoredEvent syncIgnoredEvent = (WanSyncIgnoredEvent) event;
assertNotNull(syncIgnoredEvent.getUuid());
assertNull(result.getString("uuid", null));
assertNull(syncIgnoredEvent.getMapName());
assertEquals(WAN_SYNC_IGNORED, syncIgnoredEvent.getType());
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testNestedQuery.
@Test
public void testNestedQuery() {
JsonObject object1 = Json.object();
JsonObject nested1 = Json.object();
JsonObject object2 = Json.object();
JsonObject nested2 = Json.object();
nested1.add("lim", 5);
nested2.add("lim", 6);
object1.add("inner", nested1);
object2.add("inner", nested2);
IMap<String, JsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", object1);
HazelcastJsonValue p2 = putJsonString(map, "two", object2);
Collection<JsonValue> vals = map.values(Predicates.greaterEqual("inner.lim", 6));
assertEquals(1, vals.size());
assertTrue(vals.contains(p2));
}
use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testArrayInNestedQuery.
@Test
public void testArrayInNestedQuery() {
JsonObject object1 = Json.object();
JsonObject nested1 = Json.object();
JsonObject object2 = Json.object();
JsonObject nested2 = Json.object();
JsonArray array1 = Json.array(new int[] { 1, 2, 3, 4, 5, 6 });
JsonArray array2 = Json.array(new int[] { 10, 20, 30, 40, 50, 60 });
nested1.add("arr", array1);
nested2.add("arr", array2);
object1.add("inner", nested1);
object2.add("inner", nested2);
IMap<String, JsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", object1);
HazelcastJsonValue p2 = putJsonString(map, "two", object2);
Collection<JsonValue> vals = map.values(Predicates.greaterEqual("inner.arr[2]", 20));
assertEquals(1, vals.size());
assertTrue(vals.contains(p2));
}
Aggregations