use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testQueryOnNumberPropertyOnKey_whenSomeEntriesDoNotHaveTheField_shouldNotFail.
@Test
public void testQueryOnNumberPropertyOnKey_whenSomeEntriesDoNotHaveTheField_shouldNotFail() {
IMap<JsonValue, String> map = instance.getMap(randomMapName());
JsonValue val1 = createNameAgeOnDuty("a", 30, true);
val1.asObject().add("email", "a@aa.com");
JsonValue val2 = createNameAgeOnDuty("b", 20, false);
JsonValue val3 = createNameAgeOnDuty("c", 10, true);
String p1 = putWithJsonStringKey(map, val1, "a");
String p2 = putWithJsonStringKey(map, val2, "b");
String p3 = putWithJsonStringKey(map, val3, "c");
Collection<String> vals = map.values(Predicates.equal("__key.email", "a@aa.com"));
assertEquals(1, vals.size());
assertTrue(vals.contains(p1));
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testQueryOnNumberProperty_whenSomeEntriesDoNotHaveTheField_shouldNotFail.
@Test
public void testQueryOnNumberProperty_whenSomeEntriesDoNotHaveTheField_shouldNotFail() {
IMap<String, JsonValue> map = instance.getMap(randomMapName());
JsonValue val1 = createNameAgeOnDuty("a", 30, true);
val1.asObject().add("email", "a@aa.com");
JsonValue val2 = createNameAgeOnDuty("b", 20, false);
JsonValue val3 = createNameAgeOnDuty("c", 10, true);
HazelcastJsonValue p1 = putJsonString(map, "a", val1);
HazelcastJsonValue p2 = putJsonString(map, "b", val2);
HazelcastJsonValue p3 = putJsonString(map, "c", val3);
Collection<JsonValue> vals = map.values(Predicates.equal("email", "a@aa.com"));
assertEquals(1, vals.size());
assertTrue(vals.contains(p1));
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testArrayInsideArray.
@Test
public void testArrayInsideArray() {
JsonValue array1 = Json.array();
array1.asArray().add(Json.array(new int[] { 1, 2, 3, 4 })).add(Json.array(new int[] { 10, 20, 30, 40 }));
JsonObject obj1 = Json.object();
obj1.add("arr", array1);
System.out.println(obj1);
IMap<String, JsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", obj1);
Collection<JsonValue> vals = map.values(Predicates.greaterEqual("arr[1][3]", 20));
assertEquals(1, vals.size());
assertTrue(vals.contains(p1));
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class AbstractJsonSchemaTest method validateJsonObject.
private void validateJsonObject(String originalString, JsonPattern patternPrefix, JsonObject jsonObject, JsonSchemaNode description, NavigableJsonInputAdapter input, String pathPrefix) throws IOException {
List<String> attributeNames = jsonObject.names();
for (int i = 0; i < attributeNames.size(); i++) {
String attributeName = attributeNames.get(i);
JsonValue attribute = jsonObject.get(attributeName);
JsonPattern copy = new JsonPattern(patternPrefix);
copy.add(i);
String nextPath = attributeName;
if (pathPrefix != null) {
nextPath = pathPrefix + "." + attributeName;
}
if (attribute.isObject()) {
validateJsonObject(originalString, copy, attribute.asObject(), description, input, nextPath);
} else if (attribute.isArray()) {
validateJsonArray(originalString, copy, attribute.asArray(), description, input, nextPath);
} else {
validateJsonLiteral(attribute, originalString, copy, description, input, nextPath);
}
}
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class AbstractJsonSchemaTest method testPaths.
protected void testPaths(WriterConfig config) throws IOException {
for (JsonValue value : TestJsonValues.LIST) {
String jsonString = value.toString(config);
validateJson(jsonString, value);
}
}
Aggregations