Skip to content

Commit 2cf2d06

Browse files
committed
Delombok all test source code.
Closes #2600
1 parent f8a9fdf commit 2cf2d06

17 files changed

+1869
-366
lines changed

src/test/java/org/springframework/data/redis/cache/RedisCacheTests.java

+116-25
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@
1515
*/
1616
package org.springframework.data.redis.cache;
1717

18-
import static org.assertj.core.api.Assertions.*;
19-
import static org.assertj.core.api.Assumptions.*;
20-
21-
import io.netty.util.concurrent.DefaultThreadFactory;
22-
import lombok.AllArgsConstructor;
23-
import lombok.Data;
24-
import lombok.NoArgsConstructor;
25-
import lombok.RequiredArgsConstructor;
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
20+
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
21+
import static org.assertj.core.api.Assumptions.assumeThat;
2622

2723
import java.io.Serializable;
2824
import java.nio.charset.StandardCharsets;
2925
import java.time.Duration;
3026
import java.util.Collection;
3127
import java.util.Collections;
3228
import java.util.Date;
29+
import java.util.Objects;
3330
import java.util.concurrent.CountDownLatch;
3431
import java.util.concurrent.LinkedBlockingDeque;
3532
import java.util.concurrent.ThreadPoolExecutor;
@@ -54,6 +51,8 @@
5451
import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest;
5552
import org.springframework.lang.Nullable;
5653

54+
import io.netty.util.concurrent.DefaultThreadFactory;
55+
5756
/**
5857
* Tests for {@link RedisCache} with {@link DefaultRedisCacheWriter} using different {@link RedisSerializer} and
5958
* {@link RedisConnectionFactory} pairs.
@@ -62,6 +61,7 @@
6261
* @author Mark Paluch
6362
* @author Piotr Mionskowski
6463
* @author Jos Roseboom
64+
* @author John Blum
6565
*/
6666
@MethodSource("testParams")
6767
public class RedisCacheTests {
@@ -225,15 +225,15 @@ void shouldReadAndWriteSimpleCacheKey() {
225225
@ParameterizedRedisTest // DATAREDIS-481
226226
void shouldRejectNonInvalidKey() {
227227

228-
InvalidKey key = new InvalidKey(sample.getFirstame(), sample.getBirthdate());
228+
InvalidKey key = new InvalidKey(sample.getFirstname(), sample.getBirthdate());
229229

230230
assertThatIllegalStateException().isThrownBy(() -> cache.put(key, sample));
231231
}
232232

233233
@ParameterizedRedisTest // DATAREDIS-481
234234
void shouldAllowComplexKeyWithToStringMethod() {
235235

236-
ComplexKey key = new ComplexKey(sample.getFirstame(), sample.getBirthdate());
236+
ComplexKey key = new ComplexKey(sample.getFirstname(), sample.getBirthdate());
237237

238238
cache.put(key, sample);
239239

@@ -418,31 +418,31 @@ void cacheShouldAllowArrayKeyCacheKeysOfSimpleTypes() {
418418
void cacheShouldAllowListCacheKeysOfComplexTypes() {
419419

420420
Object key = SimpleKeyGenerator
421-
.generateKey(Collections.singletonList(new ComplexKey(sample.getFirstame(), sample.getBirthdate())));
421+
.generateKey(Collections.singletonList(new ComplexKey(sample.getFirstname(), sample.getBirthdate())));
422422
cache.put(key, sample);
423423

424424
ValueWrapper target = cache.get(SimpleKeyGenerator
425-
.generateKey(Collections.singletonList(new ComplexKey(sample.getFirstame(), sample.getBirthdate()))));
425+
.generateKey(Collections.singletonList(new ComplexKey(sample.getFirstname(), sample.getBirthdate()))));
426426
assertThat(target.get()).isEqualTo(sample);
427427
}
428428

429429
@ParameterizedRedisTest // DATAREDIS-1032
430430
void cacheShouldAllowMapCacheKeys() {
431431

432432
Object key = SimpleKeyGenerator
433-
.generateKey(Collections.singletonMap("map-key", new ComplexKey(sample.getFirstame(), sample.getBirthdate())));
433+
.generateKey(Collections.singletonMap("map-key", new ComplexKey(sample.getFirstname(), sample.getBirthdate())));
434434
cache.put(key, sample);
435435

436436
ValueWrapper target = cache.get(SimpleKeyGenerator
437-
.generateKey(Collections.singletonMap("map-key", new ComplexKey(sample.getFirstame(), sample.getBirthdate()))));
437+
.generateKey(Collections.singletonMap("map-key", new ComplexKey(sample.getFirstname(), sample.getBirthdate()))));
438438
assertThat(target.get()).isEqualTo(sample);
439439
}
440440

441441
@ParameterizedRedisTest // DATAREDIS-1032
442442
void cacheShouldFailOnNonConvertibleCacheKey() {
443443

444444
Object key = SimpleKeyGenerator
445-
.generateKey(Collections.singletonList(new InvalidKey(sample.getFirstame(), sample.getBirthdate())));
445+
.generateKey(Collections.singletonList(new InvalidKey(sample.getFirstname(), sample.getBirthdate())));
446446
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> cache.put(key, sample));
447447
}
448448

@@ -537,24 +537,115 @@ void doWithConnection(Consumer<RedisConnection> callback) {
537537
}
538538
}
539539

540-
@Data
541-
@NoArgsConstructor
542-
@AllArgsConstructor
543540
static class Person implements Serializable {
544-
String firstame;
545-
Date birthdate;
541+
542+
private String firstname;
543+
private Date birthdate;
544+
545+
public Person() { }
546+
547+
public Person(String firstname, Date birthdate) {
548+
this.firstname = firstname;
549+
this.birthdate = birthdate;
550+
}
551+
552+
public String getFirstname() {
553+
return this.firstname;
554+
}
555+
556+
public void setFirstname(String firstname) {
557+
this.firstname = firstname;
558+
}
559+
560+
public Date getBirthdate() {
561+
return this.birthdate;
562+
}
563+
564+
public void setBirthdate(Date birthdate) {
565+
this.birthdate = birthdate;
566+
}
567+
568+
@Override
569+
public boolean equals(Object obj) {
570+
571+
if (this == obj) {
572+
return true;
573+
}
574+
575+
if (!(obj instanceof Person that)) {
576+
return false;
577+
}
578+
579+
return Objects.equals(this.getFirstname(), that.getFirstname())
580+
&& Objects.equals(this.getBirthdate(), that.getBirthdate());
581+
}
582+
583+
@Override
584+
public int hashCode() {
585+
return Objects.hash(getFirstname(), getBirthdate());
586+
}
587+
588+
@Override
589+
public String toString() {
590+
return "RedisCacheTests.Person(firstname=" + this.getFirstname()
591+
+ ", birthdate=" + this.getBirthdate() + ")";
592+
}
546593
}
547594

548-
@RequiredArgsConstructor // toString not overridden
595+
// toString not overridden
549596
static class InvalidKey implements Serializable {
550-
final String firstame;
597+
598+
final String firstname;
551599
final Date birthdate;
600+
601+
public InvalidKey(String firstname, Date birthdate) {
602+
this.firstname = firstname;
603+
this.birthdate = birthdate;
604+
}
552605
}
553606

554-
@Data
555-
@RequiredArgsConstructor
556607
static class ComplexKey implements Serializable {
557-
final String firstame;
608+
609+
final String firstname;
558610
final Date birthdate;
611+
612+
public ComplexKey(String firstname, Date birthdate) {
613+
this.firstname = firstname;
614+
this.birthdate = birthdate;
615+
}
616+
617+
public String getFirstname() {
618+
return this.firstname;
619+
}
620+
621+
public Date getBirthdate() {
622+
return this.birthdate;
623+
}
624+
625+
@Override
626+
public boolean equals(final Object obj) {
627+
628+
if (this == obj) {
629+
return true;
630+
}
631+
632+
if (!(obj instanceof ComplexKey that)) {
633+
return false;
634+
}
635+
636+
return Objects.equals(this.getFirstname(), that.getFirstname())
637+
&& Objects.equals(this.getBirthdate(), that.getBirthdate());
638+
}
639+
640+
@Override
641+
public int hashCode() {
642+
return Objects.hash(getFirstname(), getBirthdate());
643+
}
644+
645+
@Override
646+
public String toString() {
647+
return "RedisCacheTests.ComplexKey(firstame=" + this.getFirstname()
648+
+ ", birthdate=" + this.getBirthdate() + ")";
649+
}
559650
}
560651
}

src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactoryUnitTests.java

+87-25
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,32 @@
1515
*/
1616
package org.springframework.data.redis.connection.lettuce;
1717

18-
import static org.assertj.core.api.Assertions.*;
19-
import static org.mockito.Mockito.*;
20-
import static org.springframework.data.redis.connection.ClusterTestVariables.*;
21-
import static org.springframework.data.redis.connection.RedisConfiguration.*;
22-
import static org.springframework.data.redis.test.extension.LettuceTestClientResources.*;
23-
import static org.springframework.test.util.ReflectionTestUtils.*;
24-
25-
import io.lettuce.core.AbstractRedisClient;
26-
import io.lettuce.core.ClientOptions;
27-
import io.lettuce.core.RedisClient;
28-
import io.lettuce.core.RedisURI;
29-
import io.lettuce.core.api.StatefulConnection;
30-
import io.lettuce.core.api.StatefulRedisConnection;
31-
import io.lettuce.core.cluster.ClusterClientOptions;
32-
import io.lettuce.core.cluster.RedisClusterClient;
33-
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
34-
import io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands;
35-
import io.lettuce.core.codec.ByteArrayCodec;
36-
import io.lettuce.core.codec.RedisCodec;
37-
import io.lettuce.core.resource.ClientResources;
38-
import lombok.AllArgsConstructor;
39-
import lombok.Data;
40-
import reactor.test.StepVerifier;
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
20+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
21+
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
22+
import static org.mockito.Mockito.any;
23+
import static org.mockito.Mockito.mock;
24+
import static org.mockito.Mockito.times;
25+
import static org.mockito.Mockito.verify;
26+
import static org.mockito.Mockito.when;
27+
import static org.mockito.Mockito.withSettings;
28+
import static org.springframework.data.redis.connection.ClusterTestVariables.CLUSTER_NODE_1;
29+
import static org.springframework.data.redis.connection.RedisConfiguration.WithHostAndPort;
30+
import static org.springframework.data.redis.test.extension.LettuceTestClientResources.getSharedClientResources;
31+
import static org.springframework.test.util.ReflectionTestUtils.getField;
4132

4233
import java.time.Duration;
4334
import java.util.Collections;
35+
import java.util.Objects;
4436
import java.util.concurrent.CompletableFuture;
4537

4638
import org.junit.jupiter.api.AfterEach;
4739
import org.junit.jupiter.api.BeforeEach;
4840
import org.junit.jupiter.api.Disabled;
4941
import org.junit.jupiter.api.Test;
5042
import org.mockito.ArgumentMatchers;
43+
5144
import org.springframework.beans.DirectFieldAccessor;
5245
import org.springframework.beans.factory.DisposableBean;
5346
import org.springframework.data.redis.ConnectionFactoryTracker;
@@ -65,6 +58,22 @@
6558
import org.springframework.data.redis.test.extension.LettuceTestClientResources;
6659
import org.springframework.test.util.ReflectionTestUtils;
6760

61+
import io.lettuce.core.AbstractRedisClient;
62+
import io.lettuce.core.ClientOptions;
63+
import io.lettuce.core.RedisClient;
64+
import io.lettuce.core.RedisURI;
65+
import io.lettuce.core.api.StatefulConnection;
66+
import io.lettuce.core.api.StatefulRedisConnection;
67+
import io.lettuce.core.cluster.ClusterClientOptions;
68+
import io.lettuce.core.cluster.RedisClusterClient;
69+
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
70+
import io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands;
71+
import io.lettuce.core.codec.ByteArrayCodec;
72+
import io.lettuce.core.codec.RedisCodec;
73+
import io.lettuce.core.resource.ClientResources;
74+
75+
import reactor.test.StepVerifier;
76+
6877
/**
6978
* Unit tests for {@link LettuceConnectionFactory}.
7079
*
@@ -75,6 +84,7 @@
7584
* @author Luis De Bello
7685
* @author Andrea Como
7786
* @author Chris Bono
87+
* @author John Blum
7888
*/
7989
class LettuceConnectionFactoryUnitTests {
8090

@@ -1216,8 +1226,6 @@ void createFullRedisSentinelConfiguration() {
12161226
assertThat(configuration).isEqualTo(expected);
12171227
}
12181228

1219-
@Data
1220-
@AllArgsConstructor
12211229
static class CustomRedisConfiguration implements RedisConfiguration, WithHostAndPort {
12221230

12231231
private String hostName;
@@ -1226,5 +1234,59 @@ static class CustomRedisConfiguration implements RedisConfiguration, WithHostAnd
12261234
CustomRedisConfiguration(String hostName) {
12271235
this(hostName, 6379);
12281236
}
1237+
1238+
CustomRedisConfiguration(String hostName, int port) {
1239+
this.hostName = hostName;
1240+
this.port = port;
1241+
}
1242+
1243+
@Override
1244+
public String getHostName() {
1245+
return this.hostName;
1246+
}
1247+
1248+
@Override
1249+
public void setHostName(String hostName) {
1250+
this.hostName = hostName;
1251+
}
1252+
1253+
@Override
1254+
public int getPort() {
1255+
return this.port;
1256+
}
1257+
1258+
@Override
1259+
public void setPort(int port) {
1260+
this.port = port;
1261+
}
1262+
1263+
@Override
1264+
public boolean equals(Object obj) {
1265+
1266+
if (this == obj) {
1267+
return true;
1268+
}
1269+
1270+
if (!(obj instanceof CustomRedisConfiguration that)) {
1271+
return false;
1272+
}
1273+
1274+
return Objects.equals(this.getHostName(), that.getHostName())
1275+
&& Objects.equals(this.getPort(), that.getPort());
1276+
}
1277+
1278+
@Override
1279+
public int hashCode() {
1280+
return Objects.hash(getHostName(), getPort());
1281+
}
1282+
1283+
@Override
1284+
public String toString() {
1285+
1286+
return "CustomRedisConfiguration{" +
1287+
"hostName='" + hostName + '\'' +
1288+
", port=" + port +
1289+
'}';
1290+
}
12291291
}
12301292
}

0 commit comments

Comments
 (0)