Skip to content

Commit 1b16e64

Browse files
committed
fix tests
1 parent d07986e commit 1b16e64

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ public static <K, T, M extends Map<K, T>> boolean hasKey(MapDiff<K, T, M> diff,
147147
}
148148

149149
/**
150-
* Create a new MapDiff by transforming the keys with the provided keyFunction
150+
* Create a new JDK map backed MapDiff by transforming the keys with the provided keyFunction.
151+
* @param diff Original MapDiff to transform
152+
* @param keyFunction Function to transform the key
153+
* @param keySerializer Serializer for the new key
151154
*/
152155
public static <K1, K2, T extends Diffable<T>, M1 extends Map<K1, T>> MapDiff<K2, T, Map<K2, T>> jdkMapDiffWithUpdatedKeys(
153156
MapDiff<K1, T, M1> diff,

server/src/test/java/org/elasticsearch/snapshots/SnapshotsInProgressSerializationTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void testDiffSerializationBwc() throws IOException {
105105
out.setTransportVersion(oldVersion);
106106

107107
final Custom before = createTestInstance(() -> randomSnapshot(ProjectId.DEFAULT));
108-
final Custom after = makeTestChanges(before);
108+
final Custom after = makeTestChanges(before, () -> randomSnapshot(ProjectId.DEFAULT));
109109
final Diff<Custom> diff = after.diff(before);
110110
diff.writeTo(out);
111111

@@ -206,6 +206,10 @@ protected Writeable.Reader<Custom> instanceReader() {
206206

207207
@Override
208208
protected Custom makeTestChanges(Custom testInstance) {
209+
return makeTestChanges(testInstance, () -> randomSnapshot(randomProjectIdOrDefault()));
210+
}
211+
212+
protected Custom makeTestChanges(Custom testInstance, Supplier<Entry> randomEntrySupplier) {
209213
final SnapshotsInProgress snapshots = (SnapshotsInProgress) testInstance;
210214
SnapshotsInProgress updatedInstance = SnapshotsInProgress.EMPTY;
211215
if (randomBoolean() && snapshots.count() > 1) {
@@ -226,7 +230,7 @@ protected Custom makeTestChanges(Custom testInstance) {
226230
// add some elements
227231
int addElements = randomInt(10);
228232
for (int i = 0; i < addElements; i++) {
229-
updatedInstance = updatedInstance.withAddedEntry(randomSnapshot());
233+
updatedInstance = updatedInstance.withAddedEntry(randomEntrySupplier.get());
230234
}
231235
}
232236
if (randomBoolean()) {

0 commit comments

Comments
 (0)