Package org.elasticsearch.test
Class DiffableTestUtils
- java.lang.Object
-
- org.elasticsearch.test.DiffableTestUtils
-
public final class DiffableTestUtils extends java.lang.Object
Utilities that simplify testing of diffable classes
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
NUMBER_OF_DIFF_TEST_RUNS
-
Method Summary
Modifier and Type Method Description static <T extends Diffable<T>>
TassertDiffApplication(T remoteChanges, T localInstance, Diff<T> diffs)
Asserts that changes are applied correctly, i.e.static <T extends Writeable>
TassertSerialization(T testInstance, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader)
Asserts that testInstance can be correctly.static <T extends Writeable>
TcopyInstance(T diffs, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader)
Simulates sending diffs over the wirestatic <T extends Diffable<T>>
voidtestDiffableSerialization(java.util.function.Supplier<T> testInstance, java.util.function.Function<T,T> modifier, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader, Writeable.Reader<Diff<T>> diffReader)
Tests making random changes to an object, calculating diffs for these changes, sending this diffs over the wire and appling these diffs on the other side.
-
-
-
Field Detail
-
NUMBER_OF_DIFF_TEST_RUNS
protected static final int NUMBER_OF_DIFF_TEST_RUNS
- See Also:
- Constant Field Values
-
-
Method Detail
-
assertDiffApplication
public static <T extends Diffable<T>> T assertDiffApplication(T remoteChanges, T localInstance, Diff<T> diffs)
Asserts that changes are applied correctly, i.e. that applying diffs to localInstance produces that object equal but not the same as the remoteChanges instance.
-
copyInstance
public static <T extends Writeable> T copyInstance(T diffs, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader) throws java.io.IOException
Simulates sending diffs over the wire- Throws:
java.io.IOException
-
testDiffableSerialization
public static <T extends Diffable<T>> void testDiffableSerialization(java.util.function.Supplier<T> testInstance, java.util.function.Function<T,T> modifier, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader, Writeable.Reader<Diff<T>> diffReader) throws java.io.IOException
Tests making random changes to an object, calculating diffs for these changes, sending this diffs over the wire and appling these diffs on the other side.- Throws:
java.io.IOException
-
assertSerialization
public static <T extends Writeable> T assertSerialization(T testInstance, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader) throws java.io.IOException
Asserts that testInstance can be correctly.- Throws:
java.io.IOException
-
-