Skip to content

Commit 31b9ce5

Browse files
committed
Fix the test
Try to run mvn formatter:format Try to format the file Revert "Try to format the file" This reverts commit 535c051. Format ControlCommandsTest
1 parent 034c910 commit 31b9ce5

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

src/main/java/redis/clients/jedis/JedisClusterInfoCache.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public void run() {
6868
}
6969
}
7070

71-
public JedisClusterInfoCache(final JedisClientConfig clientConfig, final Set<HostAndPort> startNodes) {
71+
public JedisClusterInfoCache(final JedisClientConfig clientConfig,
72+
final Set<HostAndPort> startNodes) {
7273
this(clientConfig, null, null, startNodes);
7374
}
7475

@@ -107,10 +108,11 @@ public JedisClusterInfoCache(final JedisClientConfig clientConfig, Cache clientS
107108
clientConfig.getAuthXManager().start();
108109
}
109110
if (topologyRefreshPeriod != null) {
110-
logger.info("Cluster topology refresh start, period: {}, startNodes: {}", topologyRefreshPeriod, startNodes);
111+
logger.info("Cluster topology refresh start, period: {}, startNodes: {}",
112+
topologyRefreshPeriod, startNodes);
111113
topologyRefreshExecutor = Executors.newSingleThreadScheduledExecutor();
112-
topologyRefreshExecutor.scheduleWithFixedDelay(new TopologyRefreshTask(), topologyRefreshPeriod.toMillis(),
113-
topologyRefreshPeriod.toMillis(), TimeUnit.MILLISECONDS);
114+
topologyRefreshExecutor.scheduleWithFixedDelay(new TopologyRefreshTask(),
115+
topologyRefreshPeriod.toMillis(), topologyRefreshPeriod.toMillis(), TimeUnit.MILLISECONDS);
114116
}
115117
if (clientConfig.isReadOnlyForRedisClusterReplicas()) {
116118
replicaSlots = new ArrayList[Protocol.CLUSTER_HASHSLOTS];
@@ -120,14 +122,15 @@ public JedisClusterInfoCache(final JedisClientConfig clientConfig, Cache clientS
120122
}
121123

122124
/**
123-
* Check whether the number and order of slots in the cluster topology are equal to CLUSTER_HASHSLOTS
125+
* Check whether the number and order of slots in the cluster topology are equal to
126+
* CLUSTER_HASHSLOTS
124127
* @param slotsInfo the cluster topology
125128
* @return if slots is ok, return true, elese return false.
126129
*/
127130
private boolean checkClusterSlotSequence(List<Object> slotsInfo) {
128131
List<Integer> slots = new ArrayList<>();
129132
for (Object slotInfoObj : slotsInfo) {
130-
List<Object> slotInfo = (List<Object>)slotInfoObj;
133+
List<Object> slotInfo = (List<Object>) slotInfoObj;
131134
slots.addAll(getAssignedSlotArray(slotInfo));
132135
}
133136
Collections.sort(slots);
@@ -187,7 +190,8 @@ public void discoverClusterNodesAndSlots(Connection jedis) {
187190
}
188191

189192
public void renewClusterSlots(Connection jedis) {
190-
// If rediscovering is already in process - no need to start one more same rediscovering, just return
193+
// If rediscovering is already in process - no need to start one more same rediscovering, just
194+
// return
191195
if (rediscoverLock.tryLock()) {
192196
try {
193197
// First, if jedis is available, use jedis renew.
@@ -478,7 +482,7 @@ public void close() {
478482
}
479483

480484
public static String getNodeKey(HostAndPort hnp) {
481-
//return hnp.getHost() + ":" + hnp.getPort();
485+
// return hnp.getHost() + ":" + hnp.getPort();
482486
return hnp.toString();
483487
}
484488

src/test/java/redis/clients/jedis/commands/jedis/ControlCommandsTest.java

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.hamcrest.MatcherAssert.assertThat;
44
import static org.hamcrest.Matchers.greaterThan;
5+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
56
import static org.junit.jupiter.api.Assertions.assertEquals;
67
import static org.junit.jupiter.api.Assertions.assertFalse;
78
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -148,8 +149,8 @@ public void roleMaster() {
148149
@Test
149150
public void roleSlave() {
150151
EndpointConfig primaryEndpoint = HostAndPorts.getRedisEndpoint("standalone0");
151-
EndpointConfig secondaryEndpoint = HostAndPorts.getRedisEndpoint(
152-
"standalone4-replica-of-standalone1");
152+
EndpointConfig secondaryEndpoint = HostAndPorts
153+
.getRedisEndpoint("standalone4-replica-of-standalone1");
153154

154155
try (Jedis slave = new Jedis(secondaryEndpoint.getHostAndPort(),
155156
secondaryEndpoint.getClientConfigBuilder().build())) {
@@ -226,18 +227,18 @@ public void configGet() {
226227
Map<String, String> info = jedis.configGet("m*");
227228
assertNotNull(info);
228229
assertFalse(info.isEmpty());
229-
// assertTrue(info.size() % 2 == 0);
230+
// assertTrue(info.size() % 2 == 0);
230231
Map<byte[], byte[]> infoBinary = jedis.configGet("m*".getBytes());
231232
assertNotNull(infoBinary);
232233
assertFalse(infoBinary.isEmpty());
233-
// assertTrue(infoBinary.size() % 2 == 0);
234+
// assertTrue(infoBinary.size() % 2 == 0);
234235
}
235236

236237
@Test
237238
public void configSet() {
238239
Map<String, String> info = jedis.configGet("maxmemory");
239-
// assertEquals("maxmemory", info.get(0));
240-
// String memory = info.get(1);
240+
// assertEquals("maxmemory", info.get(0));
241+
// String memory = info.get(1);
241242
String memory = info.get("maxmemory");
242243
assertNotNull(memory);
243244
assertEquals("OK", jedis.configSet("maxmemory", "200"));
@@ -248,8 +249,8 @@ public void configSet() {
248249
public void configSetBinary() {
249250
byte[] maxmemory = SafeEncoder.encode("maxmemory");
250251
Map<byte[], byte[]> info = jedis.configGet(maxmemory);
251-
// assertArrayEquals(maxmemory, info.get(0));
252-
// byte[] memory = info.get(1);
252+
// assertArrayEquals(maxmemory, info.get(0));
253+
// byte[] memory = info.get(1);
253254
byte[] memory = info.get(maxmemory);
254255
assertNotNull(memory);
255256
assertEquals("OK", jedis.configSet(maxmemory, Protocol.toByteArray(200)));
@@ -259,13 +260,15 @@ public void configSetBinary() {
259260
@Test
260261
@SinceRedisVersion(value = "7.0.0", message = "Starting with Redis version 7.0.0: Added the ability to pass multiple pattern parameters in one call")
261262
public void configGetSetMulti() {
262-
String[] params = new String[]{"hash-max-listpack-entries", "set-max-intset-entries", "zset-max-listpack-entries"};
263+
String[] params = new String[] { "hash-max-listpack-entries", "set-max-intset-entries",
264+
"zset-max-listpack-entries" };
263265
Map<String, String> info = jedis.configGet(params);
264266
assertEquals(3, info.size());
265267
assertEquals("OK", jedis.configSet(info));
266268

267-
byte[][] bparams = new byte[][]{SafeEncoder.encode("hash-max-listpack-entries"),
268-
SafeEncoder.encode("set-max-intset-entries"), SafeEncoder.encode("zset-max-listpack-entries")};
269+
byte[][] bparams = new byte[][] { SafeEncoder.encode("hash-max-listpack-entries"),
270+
SafeEncoder.encode("set-max-intset-entries"),
271+
SafeEncoder.encode("zset-max-listpack-entries") };
269272
Map<byte[], byte[]> binfo = jedis.configGet(bparams);
270273
assertEquals(3, binfo.size());
271274
assertEquals("OK", jedis.configSetBinary(binfo));
@@ -429,23 +432,23 @@ public void memoryUsageBinary() {
429432
// Note: It has been recommended not to base MEMORY USAGE test on exact value, as the response
430433
// may subject to be 'tuned' especially targeting a major Redis release.
431434

432-
byte[] bfoo = {0x01, 0x02, 0x03, 0x04};
433-
byte[] bbar = {0x05, 0x06, 0x07, 0x08};
434-
byte[] bfoobar = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
435+
byte[] bfoo = { 0x01, 0x02, 0x03, 0x04 };
436+
byte[] bbar = { 0x05, 0x06, 0x07, 0x08 };
437+
byte[] bfoobar = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
435438

436439
jedis.set(bfoo, bbar);
437440
assertThat(jedis.memoryUsage(bfoo), greaterThan(20l));
438441

439-
jedis.lpush(bfoobar, new byte[]{0x01, 0x02}, new byte[]{0x05, 0x06}, new byte[]{0x00});
440-
assertThat(jedis.memoryUsage(bfoobar, 2), greaterThan(40l));
442+
jedis.lpush(bfoobar, new byte[] { 0x01, 0x02 }, new byte[] { 0x05, 0x06 }, new byte[] { 0x00 });
443+
assertThat(jedis.memoryUsage(bfoobar, 2), greaterThanOrEqualTo(40l));
441444

442445
assertNull(jedis.memoryUsage("roo", 2));
443446
}
444447

445448
@Test
446449
public void memoryPurge() {
447-
String memoryPurge = jedis.memoryPurge();
448-
assertNotNull(memoryPurge);
450+
String memoryPurge = jedis.memoryPurge();
451+
assertNotNull(memoryPurge);
449452
}
450453

451454
@Test
@@ -489,15 +492,16 @@ public void commandDocs() {
489492

490493
CommandDocument sortDoc = docs.get("sort");
491494
assertEquals("generic", sortDoc.getGroup());
492-
MatcherAssert.assertThat(sortDoc.getSummary(), Matchers.isOneOf(
493-
"Sort the elements in a list, set or sorted set",
495+
MatcherAssert.assertThat(sortDoc.getSummary(),
496+
Matchers.isOneOf("Sort the elements in a list, set or sorted set",
494497
"Sorts the elements in a list, a set, or a sorted set, optionally storing the result."));
495498
assertNull(sortDoc.getHistory());
496499

497500
CommandDocument setDoc = docs.get("set");
498501
assertEquals("1.0.0", setDoc.getSince());
499502
assertEquals("O(1)", setDoc.getComplexity());
500-
assertEquals("2.6.12: Added the `EX`, `PX`, `NX` and `XX` options.", setDoc.getHistory().get(0));
503+
assertEquals("2.6.12: Added the `EX`, `PX`, `NX` and `XX` options.",
504+
setDoc.getHistory().get(0));
501505
}
502506

503507
@Test
@@ -506,7 +510,8 @@ public void commandGetKeys() {
506510
List<String> keys = jedis.commandGetKeys("SORT", "mylist", "ALPHA", "STORE", "outlist");
507511
assertEquals(2, keys.size());
508512

509-
List<KeyValue<String, List<String>>> keySandFlags = jedis.commandGetKeysAndFlags("SET", "k1", "v1");
513+
List<KeyValue<String, List<String>>> keySandFlags = jedis.commandGetKeysAndFlags("SET", "k1",
514+
"v1");
510515
assertEquals("k1", keySandFlags.get(0).getKey());
511516
assertEquals(2, keySandFlags.get(0).getValue().size());
512517
}
@@ -581,17 +586,20 @@ public void commandList() {
581586
List<String> commands = jedis.commandList();
582587
assertTrue(commands.size() > 100);
583588

584-
commands = jedis.commandListFilterBy(CommandListFilterByParams.commandListFilterByParams().filterByModule("JSON"));
589+
commands = jedis.commandListFilterBy(
590+
CommandListFilterByParams.commandListFilterByParams().filterByModule("JSON"));
585591
assertEquals(0, commands.size()); // json module was not loaded
586592

587-
commands = jedis.commandListFilterBy(CommandListFilterByParams.commandListFilterByParams().filterByAclCat("admin"));
593+
commands = jedis.commandListFilterBy(
594+
CommandListFilterByParams.commandListFilterByParams().filterByAclCat("admin"));
588595
assertTrue(commands.size() > 10);
589596

590-
commands = jedis.commandListFilterBy(CommandListFilterByParams.commandListFilterByParams().filterByPattern("a*"));
597+
commands = jedis.commandListFilterBy(
598+
CommandListFilterByParams.commandListFilterByParams().filterByPattern("a*"));
591599
assertTrue(commands.size() > 10);
592600

593-
assertThrows(IllegalArgumentException.class, () ->
594-
jedis.commandListFilterBy(CommandListFilterByParams.commandListFilterByParams()));
601+
assertThrows(IllegalArgumentException.class,
602+
() -> jedis.commandListFilterBy(CommandListFilterByParams.commandListFilterByParams()));
595603
}
596604

597605
@Test

0 commit comments

Comments
 (0)