From 5d2cc13797d65cfee32188eadaea10c90404b512 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Tue, 29 Nov 2016 13:50:56 +0000 Subject: [PATCH] Fix long lines failing check and parsing tests (elastic/elasticsearch#415) Original commit: elastic/x-pack-elasticsearch@0711a9c919dbb3ab4bfd3f38eb4a05ae6e80842b --- .../prelert/job/results/PerPartitionMaxProbabilities.java | 8 +++++--- ...esTest.java => PerPartitionMaxProbabilitiesTests.java} | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) rename elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/results/{PerPartitionMaxProbabilitiesTest.java => PerPartitionMaxProbabilitiesTests.java} (95%) diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilities.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilities.java index 4944e1a6b5c..0e3bfb0df0b 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilities.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilities.java @@ -58,7 +58,8 @@ public class PerPartitionMaxProbabilities extends ToXContentToBytes implements W } else if (p.currentToken() == XContentParser.Token.VALUE_STRING) { return new Date(TimeUtils.dateStringToEpoch(p.text())); } - throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for [" + Bucket.TIMESTAMP.getPreferredName() + "]"); + throw new IllegalArgumentException( + "unexpected token [" + p.currentToken() + "] for [" + Bucket.TIMESTAMP.getPreferredName() + "]"); }, Bucket.TIMESTAMP, ObjectParser.ValueType.VALUE); PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), PartitionProbability.PARSER, PER_PARTITION_MAX_PROBABILITIES); PARSER.declareString((p, s) -> {}, Result.RESULT_TYPE); @@ -205,7 +206,7 @@ public class PerPartitionMaxProbabilities extends ToXContentToBytes implements W public static class PartitionProbability extends ToXContentToBytes implements Writeable { public static final ConstructingObjectParser PARSER = - new ConstructingObjectParser<>(PER_PARTITION_MAX_PROBABILITIES.getPreferredName(), + new ConstructingObjectParser<>("partitionProbability", a -> new PartitionProbability((String) a[0], (double) a[1])); static { @@ -266,7 +267,8 @@ public class PerPartitionMaxProbabilities extends ToXContentToBytes implements W PartitionProbability that = (PartitionProbability) other; - return Objects.equals(this.partitionValue, that.partitionValue) && this.maxNormalisedProbability == that.maxNormalisedProbability; + return Objects.equals(this.partitionValue, that.partitionValue) + && this.maxNormalisedProbability == that.maxNormalisedProbability; } } } diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilitiesTest.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilitiesTests.java similarity index 95% rename from elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilitiesTest.java rename to elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilitiesTests.java index c6dd16d0f83..2440439911d 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilitiesTest.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/results/PerPartitionMaxProbabilitiesTests.java @@ -14,11 +14,11 @@ import org.joda.time.DateTime; import java.util.ArrayList; import java.util.List; -public class PerPartitionMaxProbabilitiesTest extends AbstractSerializingTestCase { +public class PerPartitionMaxProbabilitiesTests extends AbstractSerializingTestCase { @Override protected PerPartitionMaxProbabilities createTestInstance() { - int num = randomInt(10); + int num = randomIntBetween(1, 10); List pps = new ArrayList<>(); for (int i=0; i