use of com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.PrimitiveObject in project hazelcast by hazelcast.
the class CompactStreamSerializerValueReaderSpecTest method fromObjectArrayToObjectArrayToPrimitiveArrayAnyScenarios.
// ----------------------------------------------------------------------------------------------------------
// from PORTABLE_ARRAY[any] via PORTABLE_ARRAY[any] to further PRIMITIVE_ARRAY[any] access
// ----------------------------------------------------------------------------------------------------------
private static void fromObjectArrayToObjectArrayToPrimitiveArrayAnyScenarios(List<Object[]> result) {
String method = "fromObjectArrayToObjectArrayToPrimitiveArrayAnyScenarios";
String p = method + " mixed";
// =============================================
// INPUT mixed
// =============================================
NestedGroupObject input = nested(new GroupObject[] { new GroupObject(new PrimitiveObject[0]), group(prim(1, NONE), prim(10, FULL), prim(50, NULL)), new GroupObject((PrimitiveObject[]) null), group(prim(20, FULL), prim(70, NULL)) });
PrimitiveObject p10 = prim(10, FULL);
PrimitiveObject p20 = prim(20, FULL);
result.addAll(asList(scenario(input, list(null, p10.bytes, p20.bytes), "objects[any].objects[any].bytes[any]", p), scenario(input, list(null, p10.shorts, p20.shorts), "objects[any].objects[any].shorts[any]", p), scenario(input, list(null, p10.ints, p20.ints), "objects[any].objects[any].ints[any]", p), scenario(input, list(null, p10.longs, p20.longs), "objects[any].objects[any].longs[any]", p), scenario(input, list(null, p10.floats, p20.floats), "objects[any].objects[any].floats[any]", p), scenario(input, list(null, p10.doubles, p20.doubles), "objects[any].objects[any].doubles[any]", p), scenario(input, list(null, p10.booleans, p20.booleans), "objects[any].objects[any].booleans[any]", p), scenario(input, list(null, p10.strings, p20.strings), "objects[any].objects[any].strings[any]", p)));
// =============================================
// INPUT empty
// =============================================
p = method + " empty";
NestedGroupObject inputEmpty = nested(new GroupObject[0]);
result.addAll(asList(scenario(inputEmpty, null, "objects[any].objects[any].bytes[any]", p), scenario(inputEmpty, null, "objects[any].objects[any].shorts[any]", p), scenario(inputEmpty, null, "objects[any].objects[any].ints[any]", p), scenario(inputEmpty, null, "objects[any].objects[any].longs[any]", p), scenario(inputEmpty, null, "objects[any].objects[any].floats[any]", p), scenario(inputEmpty, null, "objects[any].objects[any].doubles[any]", p), scenario(inputEmpty, null, "objects[any].objects[any].booleans[any]", p), scenario(inputEmpty, null, "objects[any].objects[any].strings[any]", p)));
// =============================================
// INPUT null
// =============================================
p = method + " null";
NestedGroupObject inputNull = nested((GroupObject[]) null);
result.addAll(asList(scenario(inputNull, null, "objects[any].objects[any].bytes[any]", p), scenario(inputNull, null, "objects[any].objects[any].shorts[any]", p), scenario(inputNull, null, "objects[any].objects[any].ints[any]", p), scenario(inputNull, null, "objects[any].objects[any].longs[any]", p), scenario(inputNull, null, "objects[any].objects[any].floats[any]", p), scenario(inputNull, null, "objects[any].objects[any].doubles[any]", p), scenario(inputNull, null, "objects[any].objects[any].booleans[any]", p), scenario(inputNull, null, "objects[any].objects[any].strings[any]", p)));
}
use of com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.PrimitiveObject in project hazelcast by hazelcast.
the class CompactStreamSerializerValueReaderSpecTest method fromObjectArrayToObjectArrayToPrimitiveScenarios.
// ----------------------------------------------------------------------------------------------------------
// from PORTABLE_ARRAY to PORTABLE_ARRAY access + further
// ----------------------------------------------------------------------------------------------------------
private static void fromObjectArrayToObjectArrayToPrimitiveScenarios(List<Object[]> result) {
String p = "fromObjectArrayToObjectArrayToPrimitiveScenarios";
// FULLy initialised primitive objects accessed from object stored in array
NestedGroupObject nestedFullGroup = nested(group(prim(1, FULL), prim(10, FULL), prim(100, FULL)));
result.addAll(asList(scenario(nestedFullGroup, ((GroupObject) (nestedFullGroup.objects[0])).objects, "objects[0].objects", p), scenario(nestedFullGroup, ((GroupObject) (nestedFullGroup.objects[0])).objects, "objects[0].objects[any]", p), scenario(nestedFullGroup, prim(1, FULL), "objects[any].objects[0]", p), scenario(nestedFullGroup, ((GroupObject) (nestedFullGroup.objects[0])).objects, "objects[any].objects[any]", p), scenario(nestedFullGroup, ((GroupObject) (nestedFullGroup.objects[0])).objects[0], "objects[0].objects[0]", p), scenario(nestedFullGroup, ((GroupObject) (nestedFullGroup.objects[0])).objects[1], "objects[0].objects[1]", p), scenario(nestedFullGroup, ((GroupObject) (nestedFullGroup.objects[0])).objects[2], "objects[0].objects[2]", p), scenario(nestedFullGroup, null, "objects[0].objects[12]", p)));
result.addAll(expandObjectArrayPrimitiveScenario(nestedFullGroup, (GroupObject) nestedFullGroup.object, "objects[0].objectArray.primitive_", p));
NestedGroupObject anyGroup = nested(new GroupObject[] { group(NULL), group(NONE), group(prim(1, FULL), prim(10, NONE), prim(50, NULL)), group(prim(2, FULL), prim(20, NONE), prim(80, NULL)) });
result.addAll(expandObjectArrayPrimitiveScenario(anyGroup, (GroupObject) anyGroup.objects[0], "objects[0].objectArray.primitive_", p));
// empty or null object array de-referenced further
NestedGroupObject nestedNullArrayGroup = nested(new GroupObject((PrimitiveObject[]) null));
result.addAll(asList(scenario(nestedNullArrayGroup, null, "objects[0].objects", p), scenario(nestedNullArrayGroup, null, "objects[0].objects[any]", p), scenario(nestedNullArrayGroup, null, "objects[any].objects[0]", p), scenario(nestedNullArrayGroup, null, "objects[any].objects[any]", p), scenario(nestedNullArrayGroup, null, "objects[0].objects[0]", p), scenario(nestedNullArrayGroup, null, "objects[0].objects[1]", p), scenario(nestedNullArrayGroup, null, "objects[0].objects[2]", p)));
result.addAll(expandObjectArrayPrimitiveScenario(nestedNullArrayGroup, (GroupObject) nestedNullArrayGroup.object, "objects[0].objectArray.primitive_", p));
NestedGroupObject nestedEmptyArrayGroup = nested(new GroupObject(new PrimitiveObject[0]));
result.addAll(asList(scenario(nestedEmptyArrayGroup, new PrimitiveObject[0], "objects[0].objects", p), scenario(nestedEmptyArrayGroup, null, "objects[0].objects[any]", p), scenario(nestedEmptyArrayGroup, null, "objects[any].objects[0]", p), scenario(nestedEmptyArrayGroup, null, "objects[any].objects[any]", p), scenario(nestedEmptyArrayGroup, null, "objects[0].objects[0]", p), scenario(nestedEmptyArrayGroup, null, "objects[0].objects[1]", p), scenario(nestedEmptyArrayGroup, null, "objects[0].objects[2]", p)));
result.addAll(expandObjectArrayPrimitiveScenario(nestedEmptyArrayGroup, (GroupObject) nestedEmptyArrayGroup.object, "objects[0].objectArray.primitive_", p));
NestedGroupObject nestedEmpty = nested(new GroupObject[0]);
result.addAll(asList(scenario(nestedEmpty, null, "objects[0].objects", p), scenario(nestedEmpty, null, "objects[0].objects[any]", p), scenario(nestedEmpty, null, "objects[any].objects[0]", p), scenario(nestedEmpty, null, "objects[any].objects[any]", p), scenario(nestedEmpty, null, "objects[0].objects[0]", p), scenario(nestedEmpty, null, "objects[0].objects[1]", p), scenario(nestedEmpty, null, "objects[0].objects[2]", p)));
result.addAll(expandObjectArrayPrimitiveScenario(nestedEmpty, (GroupObject) nestedEmpty.object, "objects[0].objectArray.primitive_", p));
NestedGroupObject nestedNull = nested((GroupObject[]) null);
result.addAll(asList(scenario(nestedNull, null, "objects[0].objects", p), scenario(nestedNull, null, "objects[0].objects[any]", p), scenario(nestedNull, null, "objects[any].objects[0]", p), scenario(nestedNull, null, "objects[any].objects[any]", p), scenario(nestedNull, null, "objects[0].objects[0]", p), scenario(nestedNull, null, "objects[0].objects[1]", p), scenario(nestedNull, null, "objects[0].objects[2]", p)));
result.addAll(expandObjectArrayPrimitiveScenario(nestedNull, (GroupObject) nestedNull.object, "objects[0].objectArray.primitive_", p));
}
use of com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.PrimitiveObject in project hazelcast by hazelcast.
the class CompactStreamSerializerValueReaderSpecTest method expandPrimitiveScenario.
/**
* Expands test cases for primitive non-array data types.
* Word "primitive_" from the pathToExplode is replaced by each primitive type and the scenario is expanded to:
* <ul>
* <li>scenario(input, result.byte_, adjustedPath + "byte_"),</li>
* <li>scenario(input, result.short_, adjustedPath + "short_"),</li>
* <li>scenario(input, result.int_, adjustedPath + "int_"),</li>
* <li>scenario(input, result.long_, adjustedPath + "long_"),</li>
* <li>scenario(input, result.float_, adjustedPath + "float_"),</li>
* <li>scenario(input, result.double_, adjustedPath + "double_"),</li>
* <li>scenario(input, result.boolean_, adjustedPath + "boolean_"),</li>
* <li>scenario(input, result.string_, adjustedPath + "string_"),</li>
* </ul>
*/
private static Collection<Object[]> expandPrimitiveScenario(Object input, Object result, String pathToExplode, String parent) {
List<Object[]> scenarios = new ArrayList<>();
Object adjustedResult;
for (PrimitiveFields primitiveFields : getPrimitives()) {
if (result instanceof PrimitiveObject) {
adjustedResult = ((PrimitiveObject) result).getPrimitive(primitiveFields);
} else {
adjustedResult = result;
}
// generic method case
scenarios.add(scenario(input, adjustedResult, pathToExplode.replace("primitive_", primitiveFields.field), parent));
}
return scenarios;
}
use of com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.PrimitiveObject in project hazelcast by hazelcast.
the class CompactStreamSerializerValueReaderSpecTest method fromObjectToObjectToPrimitiveScenarios.
// ----------------------------------------------------------------------------------------------------------
// from PORTABLE via PORTABLE to further access
// ----------------------------------------------------------------------------------------------------------
private static void fromObjectToObjectToPrimitiveScenarios(List<Object[]> result) {
String p = "fromObjectToObjectToPrimitiveScenarios";
// FULLy initialised primitive objects accessed from object stored in array
NestedGroupObject nestedFullGroup = nested(group(prim(1, FULL), prim(10, FULL), prim(100, FULL)));
result.addAll(asList(scenario(nestedFullGroup, (nestedFullGroup.object), "object", p), scenario(nestedFullGroup, ((GroupObject) (nestedFullGroup.object)).object, "object.object", p)));
result.addAll(expandPrimitiveScenario(nestedFullGroup, ((GroupObject) nestedFullGroup.object).object, "object.object.primitive_", p));
result.addAll(expandPrimitiveArrayScenario(nestedFullGroup, (PrimitiveObject) ((GroupObject) nestedFullGroup.object).object, "object.object.primitiveArray", p));
NestedGroupObject nestedFullEmptyNullGroup = nested(group(prim(1, FULL), prim(10, NONE), prim(100, NULL)));
result.addAll(expandPrimitiveScenario(nestedFullEmptyNullGroup, ((GroupObject) nestedFullEmptyNullGroup.object).object, "object.object.primitive_", p));
result.addAll(expandPrimitiveArrayScenario(nestedFullEmptyNullGroup, (PrimitiveObject) ((GroupObject) nestedFullEmptyNullGroup.object).object, "object.object.primitiveArray", p));
// empty or null object array de-referenced further
NestedGroupObject nestedNullArrayGroup = nested(new GroupObject((PrimitiveObject[]) null));
result.addAll(asList(scenario(nestedNullArrayGroup, (nestedNullArrayGroup.object), "object", p), scenario(nestedNullArrayGroup, null, "object.object", p)));
result.addAll(expandPrimitiveScenario(nestedNullArrayGroup, null, "object.object.primitive_", p));
result.addAll(expandPrimitiveArrayScenario(nestedNullArrayGroup, null, "object.object.primitiveArray", p));
NestedGroupObject nestedNull = nested(new GroupObject[0]);
result.addAll(asList(scenario(nestedNull, null, "object", p), scenario(nestedNull, null, "object.object", p)));
result.addAll(expandPrimitiveScenario(nestedNull, null, "object.object.primitive_", p));
result.addAll(expandPrimitiveArrayScenario(nestedNull, null, "object.object.primitiveArray", p));
}
use of com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.PrimitiveObject in project hazelcast by hazelcast.
the class CompactStreamSerializerValueReaderSpecTest method fromObjectArrayToObjectArrayAnyScenarios.
// ----------------------------------------------------------------------------------------------------------
// from PORTABLE_ARRAY to PORTABLE_ARRAY access + further
// ----------------------------------------------------------------------------------------------------------
private static void fromObjectArrayToObjectArrayAnyScenarios(List<Object[]> result) {
String p = "fromObjectArrayToObjectArrayAnyScenarios";
NestedGroupObject anyGroup = nested(new GroupObject[] { group(prim(1, FULL), prim(10, NONE), prim(50, NULL)), group(prim(2, FULL), prim(20, NONE), prim(80, NULL)) });
result.addAll(asList(scenario(anyGroup, ((GroupObject) (anyGroup.objects[0])).objects, "objects[0].objects[any]", p), scenario(anyGroup, new PrimitiveObject[] { prim(1, FULL), prim(2, FULL) }, "objects[any].objects[0]", p), scenario(anyGroup, new PrimitiveObject[] { prim(10, FULL), prim(20, FULL) }, "objects[any].objects[1]", p), scenario(anyGroup, new PrimitiveObject[] { prim(50, FULL), prim(80, FULL) }, "objects[any].objects[2]", p), scenario(anyGroup, new PrimitiveObject[] { prim(1, FULL), prim(10, FULL), prim(50, FULL), prim(2, FULL), prim(20, FULL), prim(80, FULL) }, "objects[any].objects[any]", p)));
NestedGroupObject nestedEmptyArrayGroup = nested(new GroupObject[] { new GroupObject(new PrimitiveObject[0]), group(prim(1, FULL), prim(10, NONE), prim(50, NULL)) });
result.addAll(asList(scenario(nestedEmptyArrayGroup, null, "objects[0].objects[any]", p), scenario(nestedEmptyArrayGroup, new PrimitiveObject[] { null, prim(1, FULL) }, "objects[any].objects[0]", p), scenario(nestedEmptyArrayGroup, new PrimitiveObject[] { null, prim(10, FULL) }, "objects[any].objects[1]", p), scenario(nestedEmptyArrayGroup, new PrimitiveObject[] { null, prim(50, FULL) }, "objects[any].objects[2]", p), scenario(nestedEmptyArrayGroup, new PrimitiveObject[] { null, prim(1, FULL), prim(10, FULL), prim(50, FULL) }, "objects[any].objects[any]", p)));
NestedGroupObject nestedNullArrayGroup = nested(new GroupObject[] { new GroupObject((PrimitiveObject[]) null), group(prim(1, FULL), prim(10, NONE), prim(50, NULL)) });
result.addAll(asList(scenario(nestedNullArrayGroup, null, "objects[0].objects[any]", p), scenario(nestedNullArrayGroup, new PrimitiveObject[] { null, prim(1, FULL) }, "objects[any].objects[0]", p), scenario(nestedNullArrayGroup, new PrimitiveObject[] { null, prim(10, FULL) }, "objects[any].objects[1]", p), scenario(nestedNullArrayGroup, new PrimitiveObject[] { null, prim(50, FULL) }, "objects[any].objects[2]", p), scenario(nestedNullArrayGroup, new PrimitiveObject[] { null, prim(1, FULL), prim(10, FULL), prim(50, FULL) }, "objects[any].objects[any]", p)));
}
Aggregations