From 50ce990305704b4ab055f9cd586f665dbbfc37d3 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 19 Jun 2018 10:22:42 +0200 Subject: [PATCH] added missing serialization tests --- .../action/CreateAndFollowIndexAction.java | 29 +++++++++++++++++ .../xpack/ccr/action/FollowIndexAction.java | 20 ++++++++++++ .../CreateAndFollowIndexRequestTests.java | 23 ++++++++++++++ .../CreateAndFollowIndexResponseTests.java | 21 +++++++++++++ .../ccr/action/FollowIndexRequestTests.java | 31 +++++++++++++++++++ 5 files changed, 124 insertions(+) create mode 100644 x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexRequestTests.java create mode 100644 x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java create mode 100644 x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java index 0085f7db9fa..a71ed64ac33 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexAction.java @@ -45,6 +45,7 @@ import org.elasticsearch.xpack.ccr.CcrSettings; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Objects; public class CreateAndFollowIndexAction extends Action { @@ -89,6 +90,19 @@ public class CreateAndFollowIndexAction extends Action { diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowIndexAction.java index d10aa90a5d4..8c58407123c 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowIndexAction.java @@ -47,6 +47,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReferenceArray; @@ -127,6 +128,7 @@ public class FollowIndexAction extends Action { + + @Override + protected CreateAndFollowIndexAction.Request createBlankInstance() { + return new CreateAndFollowIndexAction.Request(); + } + + @Override + protected CreateAndFollowIndexAction.Request createTestInstance() { + CreateAndFollowIndexAction.Request request = new CreateAndFollowIndexAction.Request(); + request.setFollowRequest(FollowIndexRequestTests.createTestRequest()); + return request; + } +} diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java new file mode 100644 index 00000000000..11a518ef067 --- /dev/null +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/CreateAndFollowIndexResponseTests.java @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.ccr.action; + +import org.elasticsearch.test.AbstractStreamableTestCase; + +public class CreateAndFollowIndexResponseTests extends AbstractStreamableTestCase { + + @Override + protected CreateAndFollowIndexAction.Response createBlankInstance() { + return new CreateAndFollowIndexAction.Response(); + } + + @Override + protected CreateAndFollowIndexAction.Response createTestInstance() { + return new CreateAndFollowIndexAction.Response(randomBoolean(), randomBoolean(), randomBoolean()); + } +} diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java new file mode 100644 index 00000000000..9a0557b369a --- /dev/null +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowIndexRequestTests.java @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.ccr.action; + +import org.elasticsearch.test.AbstractStreamableTestCase; + +public class FollowIndexRequestTests extends AbstractStreamableTestCase { + + @Override + protected FollowIndexAction.Request createBlankInstance() { + return new FollowIndexAction.Request(); + } + + @Override + protected FollowIndexAction.Request createTestInstance() { + return createTestRequest(); + } + + static FollowIndexAction.Request createTestRequest() { + FollowIndexAction.Request request = new FollowIndexAction.Request(); + request.setLeaderIndex(randomAlphaOfLength(4)); + request.setFollowIndex(randomAlphaOfLength(4)); + request.setBatchSize(randomNonNegativeLong()); + request.setConcurrentProcessors(randomIntBetween(0, Integer.MAX_VALUE)); + request.setProcessorMaxTranslogBytes(randomNonNegativeLong()); + return request; + } +}