use of org.elasticsearch.test.EqualsHashCodeTestUtils.CopyFunction in project crate by crate.
the class CoordinationMetadataTests method testCoordinationMetadataSerializationEqualsHashCode.
public void testCoordinationMetadataSerializationEqualsHashCode() {
CoordinationMetadata initialMetadata = new CoordinationMetadata(randomNonNegativeLong(), randomVotingConfig(), randomVotingConfig(), randomVotingTombstones());
// Note: the explicit cast of the CopyFunction is needed for some IDE (specifically Eclipse 4.8.0) to infer the right type
EqualsHashCodeTestUtils.checkEqualsAndHashCode(initialMetadata, (CopyFunction<CoordinationMetadata>) orig -> ESTestCase.copyWriteable(orig, new NamedWriteableRegistry(Collections.emptyList()), CoordinationMetadata::new), meta -> {
CoordinationMetadata.Builder builder = CoordinationMetadata.builder(meta);
switch(randomInt(3)) {
case 0:
builder.term(randomValueOtherThan(meta.term(), ESTestCase::randomNonNegativeLong));
break;
case 1:
builder.lastCommittedConfiguration(randomlyChangeVotingConfiguration(meta.getLastCommittedConfiguration()));
break;
case 2:
builder.lastAcceptedConfiguration(randomlyChangeVotingConfiguration(meta.getLastAcceptedConfiguration()));
break;
case 3:
if (meta.getVotingConfigExclusions().isEmpty() == false && randomBoolean()) {
builder.clearVotingConfigExclusions();
} else {
randomVotingTombstones().forEach(dn -> builder.addVotingConfigExclusion(dn));
}
break;
}
return builder.build();
});
}
use of org.elasticsearch.test.EqualsHashCodeTestUtils.CopyFunction in project crate by crate.
the class LeaderCheckerTests method testLeaderCheckRequestEqualsHashcodeSerialization.
public void testLeaderCheckRequestEqualsHashcodeSerialization() {
LeaderCheckRequest request = new LeaderCheckRequest(new DiscoveryNode(randomAlphaOfLength(10), buildNewFakeTransportAddress(), Version.CURRENT));
// Note: the explicit cast of the CopyFunction is needed for some IDE (specifically Eclipse 4.8.0) to infer the right type
EqualsHashCodeTestUtils.checkEqualsAndHashCode(request, (CopyFunction<LeaderCheckRequest>) rq -> copyWriteable(rq, writableRegistry(), LeaderCheckRequest::new), rq -> new LeaderCheckRequest(new DiscoveryNode(randomAlphaOfLength(10), buildNewFakeTransportAddress(), Version.CURRENT)));
}
use of org.elasticsearch.test.EqualsHashCodeTestUtils.CopyFunction in project crate by crate.
the class CoordinationMetadataTests method testVotingTombstoneSerializationEqualsHashCode.
public void testVotingTombstoneSerializationEqualsHashCode() {
VotingConfigExclusion tombstone = new VotingConfigExclusion(randomAlphaOfLength(10), randomAlphaOfLength(10));
// Note: the explicit cast of the CopyFunction is needed for some IDE (specifically Eclipse 4.8.0) to infer the right type
EqualsHashCodeTestUtils.checkEqualsAndHashCode(tombstone, (CopyFunction<VotingConfigExclusion>) orig -> ESTestCase.copyWriteable(orig, new NamedWriteableRegistry(Collections.emptyList()), VotingConfigExclusion::new), orig -> randomlyChangeVotingTombstone(orig));
}
use of org.elasticsearch.test.EqualsHashCodeTestUtils.CopyFunction in project crate by crate.
the class CoordinationMetadataTests method testVotingConfigurationSerializationEqualsHashCode.
public void testVotingConfigurationSerializationEqualsHashCode() {
VotingConfiguration initialConfig = randomVotingConfig();
// Note: the explicit cast of the CopyFunction is needed for some IDE (specifically Eclipse 4.8.0) to infer the right type
EqualsHashCodeTestUtils.checkEqualsAndHashCode(initialConfig, (CopyFunction<VotingConfiguration>) orig -> ESTestCase.copyWriteable(orig, new NamedWriteableRegistry(Collections.emptyList()), VotingConfiguration::new), cfg -> randomlyChangeVotingConfiguration(cfg));
}
Aggregations