Fix equalsAndHashCode in ClientCompactQueryTuningConfig (#9035)

* Fix equalsAndHashCode in ClientCompactQueryTuningConfig

This change introduces a dependency to EqualsVerifier for the test scope.
The dependency is licensed under Apache 2. The library makes it trivial
to add equals and hashCode checks to prevent bugs like this from happening
in the future

* fix checkstyle

* fix test name
This commit is contained in:
Suneet Saldanha 2019-12-16 14:33:00 -08:00 committed by Jonathan Wei
parent 298425a33a
commit 301c0649a7
4 changed files with 48 additions and 0 deletions

View File

@ -1198,6 +1198,12 @@
<version>${guava.version}</version> <version>${guava.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.1.10</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>com.github.stefanbirkner</groupId> <groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId> <artifactId>system-rules</artifactId>

View File

@ -421,6 +421,11 @@
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -193,6 +193,7 @@ public class ClientCompactQueryTuningConfig
Objects.equals(maxBytesInMemory, that.maxBytesInMemory) && Objects.equals(maxBytesInMemory, that.maxBytesInMemory) &&
Objects.equals(maxRowsInMemory, that.maxRowsInMemory) && Objects.equals(maxRowsInMemory, that.maxRowsInMemory) &&
Objects.equals(maxTotalRows, that.maxTotalRows) && Objects.equals(maxTotalRows, that.maxTotalRows) &&
Objects.equals(splitHintSpec, that.splitHintSpec) &&
Objects.equals(indexSpec, that.indexSpec) && Objects.equals(indexSpec, that.indexSpec) &&
Objects.equals(maxPendingPersists, that.maxPendingPersists) && Objects.equals(maxPendingPersists, that.maxPendingPersists) &&
Objects.equals(pushTimeout, that.pushTimeout) && Objects.equals(pushTimeout, that.pushTimeout) &&
@ -207,6 +208,7 @@ public class ClientCompactQueryTuningConfig
maxBytesInMemory, maxBytesInMemory,
maxRowsInMemory, maxRowsInMemory,
maxTotalRows, maxTotalRows,
splitHintSpec,
indexSpec, indexSpec,
maxPendingPersists, maxPendingPersists,
pushTimeout, pushTimeout,
@ -222,6 +224,7 @@ public class ClientCompactQueryTuningConfig
", maxBytesInMemory=" + maxBytesInMemory + ", maxBytesInMemory=" + maxBytesInMemory +
", maxRowsInMemory=" + maxRowsInMemory + ", maxRowsInMemory=" + maxRowsInMemory +
", maxTotalRows=" + maxTotalRows + ", maxTotalRows=" + maxTotalRows +
", splitHintSpec=" + splitHintSpec +
", indexSpec=" + indexSpec + ", indexSpec=" + indexSpec +
", maxPendingPersists=" + maxPendingPersists + ", maxPendingPersists=" + maxPendingPersists +
", pushTimeout=" + pushTimeout + ", pushTimeout=" + pushTimeout +

View File

@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.druid.indexing;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.client.indexing.ClientCompactQueryTuningConfig;
import org.junit.Test;
public class ClientCompactQueryTuningConfigTest
{
@Test
public void testEqualsContract()
{
// If this test failed, make sure to validate that toString was also updated correctly!
EqualsVerifier.forClass(ClientCompactQueryTuningConfig.class).usingGetClass().verify();
}
}