Java Code Examples for org.apache.flink.testutils.DeeplyEqualsChecker

The following examples show how to use org.apache.flink.testutils.DeeplyEqualsChecker. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Flink-CEPplus   Source File: UnionSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public UnionSerializerTest() {
	super(new DeeplyEqualsChecker()
		.withCustomCheck(
			(o1, o2) -> o1 instanceof TaggedUnion && o2 instanceof TaggedUnion,
			(o1, o2, checker) -> {
				TaggedUnion union1 = (TaggedUnion) o1;
				TaggedUnion union2 = (TaggedUnion) o2;

				if (union1.isOne() && union2.isOne()) {
					return checker.deepEquals(union1.getOne(), union2.getOne());
				} else if (union1.isTwo() && union2.isTwo()) {
					return checker.deepEquals(union1.getTwo(), union2.getTwo());
				} else {
					return false;
				}
			}
		));
}
 
Example 2
Source Project: flink   Source File: BaseRowSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public BaseRowSerializerTest(BaseRowSerializer serializer, BaseRow[] testData) {
	super(
		new DeeplyEqualsChecker()
			.withCustomCheck(
				(o1, o2) -> o1 instanceof BaseRow && o2 instanceof BaseRow,
					(o1, o2, checker) -> deepEqualsBaseRow((BaseRow) o1, (BaseRow) o2,
							(BaseRowSerializer) serializer.duplicate(),
							(BaseRowSerializer) serializer.duplicate())
			),
		serializer,
		BaseRow.class,
		-1,
		testData);
	this.serializer = serializer;
	this.testData = testData;
}
 
Example 3
Source Project: flink   Source File: BaseArraySerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public BaseArraySerializerTest() {
	super(new DeeplyEqualsChecker().withCustomCheck(
			(o1, o2) -> o1 instanceof BaseArray && o2 instanceof BaseArray,
			(o1, o2, checker) -> {
				BaseArray array1 = (BaseArray) o1;
				BaseArray array2 = (BaseArray) o2;
				if (array1.numElements() != array2.numElements()) {
					return false;
				}
				for (int i = 0; i < array1.numElements(); i++) {
					if (!array1.isNullAt(i) || !array2.isNullAt(i)) {
						if (array1.isNullAt(i) || array2.isNullAt(i)) {
							return false;
						} else {
							if (!array1.getString(i).equals(array2.getString(i))) {
								return false;
							}
						}
					}
				}
				return true;
			}
	));
}
 
Example 4
Source Project: flink   Source File: UnionSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public UnionSerializerTest() {
	super(new DeeplyEqualsChecker()
	.withCustomCheck(
		(o1, o2) -> o1 instanceof TaggedUnion && o2 instanceof TaggedUnion,
		(o1, o2, checker) -> {
			TaggedUnion union1 = (TaggedUnion) o1;
			TaggedUnion union2 = (TaggedUnion) o2;

			if (union1.isOne() && union2.isOne()) {
				return checker.deepEquals(union1.getOne(), union2.getOne());
			} else if (union1.isTwo() && union2.isTwo()) {
				return checker.deepEquals(union1.getTwo(), union2.getTwo());
			} else {
				return false;
			}
		}
	));
}
 
Example 5
Source Project: flink   Source File: ArrayDataSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public ArrayDataSerializerTest() {
	super(new DeeplyEqualsChecker().withCustomCheck(
			(o1, o2) -> o1 instanceof ArrayData && o2 instanceof ArrayData,
			(o1, o2, checker) -> {
				ArrayData array1 = (ArrayData) o1;
				ArrayData array2 = (ArrayData) o2;
				if (array1.size() != array2.size()) {
					return false;
				}
				for (int i = 0; i < array1.size(); i++) {
					if (!array1.isNullAt(i) || !array2.isNullAt(i)) {
						if (array1.isNullAt(i) || array2.isNullAt(i)) {
							return false;
						} else {
							if (!array1.getString(i).equals(array2.getString(i))) {
								return false;
							}
						}
					}
				}
				return true;
			}
	));
}
 
Example 6
Source Project: flink   Source File: RowDataSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public RowDataSerializerTest(RowDataSerializer serializer, RowData[] testData) {
	super(
		new DeeplyEqualsChecker()
			.withCustomCheck(
				(o1, o2) -> o1 instanceof RowData && o2 instanceof RowData,
					(o1, o2, checker) -> deepEqualsRowData((RowData) o1, (RowData) o2,
							(RowDataSerializer) serializer.duplicate(),
							(RowDataSerializer) serializer.duplicate())
			),
		serializer,
		RowData.class,
		-1,
		testData);
	this.serializer = serializer;
	this.testData = testData;
}
 
Example 7
Source Project: flink   Source File: RowDataSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public RowDataSerializerTest() {
	super(
		new DeeplyEqualsChecker()
			.withCustomCheck(
				(o1, o2) -> o1 instanceof RowData && o2 instanceof RowData,
				(o1, o2, checker) -> {
					LogicalType[] fieldTypes = new LogicalType[] {
						new BigIntType(),
						new BigIntType()
					};
					RowDataSerializer serializer = new RowDataSerializer(new ExecutionConfig(), fieldTypes);
					return deepEqualsRowData(
						(RowData) o1,
						(RowData) o2,
						(RowDataSerializer) serializer.duplicate(),
						(RowDataSerializer) serializer.duplicate());
				}
			));
}
 
Example 8
Source Project: flink   Source File: UnionSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
public UnionSerializerTest() {
	super(new DeeplyEqualsChecker()
	.withCustomCheck(
		(o1, o2) -> o1 instanceof TaggedUnion && o2 instanceof TaggedUnion,
		(o1, o2, checker) -> {
			TaggedUnion union1 = (TaggedUnion) o1;
			TaggedUnion union2 = (TaggedUnion) o2;

			if (union1.isOne() && union2.isOne()) {
				return checker.deepEquals(union1.getOne(), union2.getOne());
			} else if (union1.isTwo() && union2.isTwo()) {
				return checker.deepEquals(union1.getTwo(), union2.getTwo());
			} else {
				return false;
			}
		}
	));
}
 
Example 9
Source Project: Flink-CEPplus   Source File: SerializerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
SerializerRunner(
	CyclicBarrier allReadyBarrier,
	TypeSerializer<T> serializer,
	T[] testData,
	long testTargetDurationMillis, DeeplyEqualsChecker checker) {

	this.allReadyBarrier = allReadyBarrier;
	this.serializer = serializer;
	this.testData = testData;
	this.durationLimitMillis =  testTargetDurationMillis;
	this.checker = checker;
	this.failure = null;
}
 
Example 10
Source Project: Flink-CEPplus   Source File: SerializerTestInstance.java    License: Apache License 2.0 5 votes vote down vote up
@SafeVarargs
public SerializerTestInstance(
		DeeplyEqualsChecker checker,
		TypeSerializer<T> serializer,
		Class<T> typeClass,
		int length,
		T... testData) {
	super(checker);
	this.serializer = serializer;
	this.typeClass = typeClass;
	this.length = length;
	this.testData = testData;
}
 
Example 11
ValueArraySerializerTestBase() {
	super(
		new DeeplyEqualsChecker()
			.withCustomCheck(
				(o1, o2) -> o1 instanceof ValueArray && o2 instanceof ValueArray,
				(o1, o2, checker) -> Objects.equals(o1, o2)));
}
 
Example 12
Source Project: flink   Source File: BaseMapSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
public BaseMapSerializerTest() {
	super(new DeeplyEqualsChecker().withCustomCheck(
			(o1, o2) -> o1 instanceof BaseMap && o2 instanceof BaseMap,
			(o1, o2, checker) ->
					// Better is more proper to compare the maps after changing them to Java maps
					// instead of binary maps. For example, consider the following two maps:
					// {1: 'a', 2: 'b', 3: 'c'} and {3: 'c', 2: 'b', 1: 'a'}
					// These are actually the same maps, but their key / value order will be
					// different when stored as binary maps, and the equalsTo method of binary
					// map will return false.
					((BaseMap) o1).toJavaMap(INT, STRING)
							.equals(((BaseMap) o2).toJavaMap(INT, STRING))
	));
}
 
Example 13
Source Project: flink   Source File: SerializerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
SerializerRunner(
	CyclicBarrier allReadyBarrier,
	TypeSerializer<T> serializer,
	T[] testData,
	long testTargetDurationMillis, DeeplyEqualsChecker checker) {

	this.allReadyBarrier = allReadyBarrier;
	this.serializer = serializer;
	this.testData = testData;
	this.durationLimitMillis =  testTargetDurationMillis;
	this.checker = checker;
	this.failure = null;
}
 
Example 14
Source Project: flink   Source File: SerializerTestInstance.java    License: Apache License 2.0 5 votes vote down vote up
@SafeVarargs
public SerializerTestInstance(
		DeeplyEqualsChecker checker,
		TypeSerializer<T> serializer,
		Class<T> typeClass,
		int length,
		T... testData) {
	super(checker);
	this.serializer = serializer;
	this.typeClass = typeClass;
	this.length = length;
	this.testData = testData;
}
 
Example 15
Source Project: flink   Source File: ValueArraySerializerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
ValueArraySerializerTestBase() {
	super(
		new DeeplyEqualsChecker()
			.withCustomCheck(
				(o1, o2) -> o1 instanceof ValueArray && o2 instanceof ValueArray,
				(o1, o2, checker) -> Objects.equals(o1, o2)));
}
 
Example 16
public TaggedBootstrapDataSerializerTest() {
    super(
            new DeeplyEqualsChecker().withCustomCheck(
                    (o1, o2) -> o1 instanceof TaggedBootstrapData && o2 instanceof TaggedBootstrapData,
                    (o1, o2, checker) -> {
                        TaggedBootstrapData obj1 = (TaggedBootstrapData) o1;
                        TaggedBootstrapData obj2 = (TaggedBootstrapData) o2;
                        return obj1.getTarget().equals(obj2.getTarget())
                                && obj1.getUnionIndex() == obj2.getUnionIndex()
                                // equality checks on payload makes sense here since
                                // the payloads are only booleans or integers in this test
                                && obj1.getPayload().equals(obj2.getPayload());
                    }));
}
 
Example 17
public TaggedBootstrapDataSerializerTest() {
  super(
      new DeeplyEqualsChecker()
          .withCustomCheck(
              (o1, o2) -> o1 instanceof TaggedBootstrapData && o2 instanceof TaggedBootstrapData,
              (o1, o2, checker) -> {
                TaggedBootstrapData obj1 = (TaggedBootstrapData) o1;
                TaggedBootstrapData obj2 = (TaggedBootstrapData) o2;
                return obj1.getTarget().equals(obj2.getTarget())
                    && obj1.getUnionIndex() == obj2.getUnionIndex()
                    // equality checks on payload makes sense here since
                    // the payloads are only booleans or integers in this test
                    && obj1.getPayload().equals(obj2.getPayload());
              }));
}
 
Example 18
Source Project: flink   Source File: MapDataSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
public MapDataSerializerTest() {
	super(new DeeplyEqualsChecker().withCustomCheck(
			(o1, o2) -> o1 instanceof MapData && o2 instanceof MapData,
			(o1, o2, checker) ->
					// Better is more proper to compare the maps after changing them to Java maps
					// instead of binary maps. For example, consider the following two maps:
					// {1: 'a', 2: 'b', 3: 'c'} and {3: 'c', 2: 'b', 1: 'a'}
					// These are actually the same maps, but their key / value order will be
					// different when stored as binary maps, and the equalsTo method of binary
					// map will return false.
					convertToJavaMap((MapData) o1, INT, STRING)
						.equals(convertToJavaMap((MapData) o2, INT, STRING))
	));
}
 
Example 19
Source Project: flink   Source File: RawValueDataSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
public RawValueDataSerializerTest() {
	super(new DeeplyEqualsChecker()
		.withCustomCheck(
			(o, o2) -> o instanceof RawValueData && o2 instanceof RawValueData,
			(o, o2, checker) -> RawValueDataAsserter.equivalent(
				(RawValueData) o2,
				new RawValueDataSerializer<>(StringSerializer.INSTANCE)).matches(o)
		));
}
 
Example 20
Source Project: flink   Source File: MapDataSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
public MapDataSerializerTest() {
	super(new DeeplyEqualsChecker().withCustomCheck(
		(o1, o2) -> o1 instanceof MapData && o2 instanceof MapData,
		(o1, o2, checker) ->
			// Better is more proper to compare the maps after changing them to Java maps
			// instead of binary maps. For example, consider the following two maps:
			// {1: 1.0F, 2: 2.0F, 3: 3.0F} and {3: 3.0F, 2: 2.0F, 1: 1.0F}
			// These are actually the same maps, but their key / value order will be
			// different when stored as binary maps, and the equalsTo method of binary
			// map will return false.
			convertToJavaMap((MapData) o1, BIGINT, FLOAT)
				.equals(convertToJavaMap((MapData) o2, BIGINT, FLOAT))
	));
}
 
Example 21
Source Project: flink   Source File: RowDataArrowReaderWriterTest.java    License: Apache License 2.0 5 votes vote down vote up
public RowDataArrowReaderWriterTest() {
	super(new DeeplyEqualsChecker()
		.withCustomCheck(
			(o1, o2) -> o1 instanceof RowData && o2 instanceof RowData,
			(o1, o2, checker) -> {
				RowDataSerializer serializer = new RowDataSerializer(
					new ExecutionConfig(), fieldTypes.toArray(new LogicalType[0]));
				return deepEqualsRowData(
					(RowData) o1,
					(RowData) o2,
					(RowDataSerializer) serializer.duplicate(),
					(RowDataSerializer) serializer.duplicate());
			}));
}
 
Example 22
Source Project: flink   Source File: ArrowSourceFunctionTest.java    License: Apache License 2.0 5 votes vote down vote up
public ArrowSourceFunctionTest() {
	super(VectorSchemaRoot.create(ArrowUtils.toArrowSchema(rowType), allocator),
		serializer,
		Comparator.comparing(o -> o.getString(0)),
		new DeeplyEqualsChecker()
			.withCustomCheck(
				(o1, o2) -> o1 instanceof RowData && o2 instanceof RowData,
				(o1, o2, checker) -> deepEqualsBaseRow(
					(RowData) o1,
					(RowData) o2,
					(RowDataSerializer) serializer.duplicate(),
					(RowDataSerializer) serializer.duplicate())));
}
 
Example 23
Source Project: flink   Source File: SerializerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
SerializerRunner(
	CyclicBarrier allReadyBarrier,
	TypeSerializer<T> serializer,
	T[] testData,
	long testTargetDurationMillis, DeeplyEqualsChecker checker) {

	this.allReadyBarrier = allReadyBarrier;
	this.serializer = serializer;
	this.testData = testData;
	this.durationLimitMillis =  testTargetDurationMillis;
	this.checker = checker;
	this.failure = null;
}
 
Example 24
Source Project: flink   Source File: SerializerTestInstance.java    License: Apache License 2.0 5 votes vote down vote up
@SafeVarargs
public SerializerTestInstance(
		DeeplyEqualsChecker checker,
		TypeSerializer<T> serializer,
		Class<T> typeClass,
		int length,
		T... testData) {
	super(checker);
	this.serializer = serializer;
	this.typeClass = typeClass;
	this.length = length;
	this.testData = testData;
}
 
Example 25
Source Project: flink   Source File: ValueArraySerializerTestBase.java    License: Apache License 2.0 5 votes vote down vote up
ValueArraySerializerTestBase() {
	super(
		new DeeplyEqualsChecker()
			.withCustomCheck(
				(o1, o2) -> o1 instanceof ValueArray && o2 instanceof ValueArray,
				(o1, o2, checker) -> Objects.equals(o1, o2)));
}
 
Example 26
Source Project: Flink-CEPplus   Source File: SerializerTestBase.java    License: Apache License 2.0 4 votes vote down vote up
protected SerializerTestBase() {
	this.checker = new DeeplyEqualsChecker();
}
 
Example 27
Source Project: Flink-CEPplus   Source File: SerializerTestBase.java    License: Apache License 2.0 4 votes vote down vote up
protected SerializerTestBase(DeeplyEqualsChecker checker) {
	this.checker = checker;
}
 
Example 28
Source Project: Flink-CEPplus   Source File: SerializerTestInstance.java    License: Apache License 2.0 4 votes vote down vote up
@SafeVarargs
public SerializerTestInstance(TypeSerializer<T> serializer, Class<T> typeClass, int length, T... testData) {
	this(new DeeplyEqualsChecker(), serializer, typeClass, length, testData);
}
 
Example 29
Source Project: flink   Source File: SerializerTestBase.java    License: Apache License 2.0 4 votes vote down vote up
protected SerializerTestBase() {
	this.checker = new DeeplyEqualsChecker();
}
 
Example 30
Source Project: flink   Source File: SerializerTestBase.java    License: Apache License 2.0 4 votes vote down vote up
protected SerializerTestBase(DeeplyEqualsChecker checker) {
	this.checker = checker;
}