2424
2525import java .io .Serializable ;
2626import java .nio .charset .Charset ;
27+ import java .nio .charset .StandardCharsets ;
2728import java .util .Collection ;
2829import java .util .Collections ;
2930import java .util .Date ;
@@ -57,7 +58,7 @@ public class RedisCacheTests {
5758
5859 String key = "key-1" ;
5960 String cacheKey = "cache::" + key ;
60- byte [] binaryCacheKey = cacheKey .getBytes (Charset . forName ( "UTF-8" ) );
61+ byte [] binaryCacheKey = cacheKey .getBytes (StandardCharsets . UTF_8 );
6162
6263 Person sample = new Person ("calmity" , new Date ());
6364 byte [] binarySample ;
@@ -281,15 +282,15 @@ public void computePrefixCreatesCacheKeyCorrectly() {
281282
282283 doWithConnection (connection -> {
283284
284- assertThat (connection .stringCommands ().get ("_cache_key-1" .getBytes (Charset . forName ( "UTF-8" ) )))
285+ assertThat (connection .stringCommands ().get ("_cache_key-1" .getBytes (StandardCharsets . UTF_8 )))
285286 .isEqualTo (binarySample );
286287 });
287288 }
288289
289290 @ Test // DATAREDIS-715
290291 public void fetchKeyWithComputedPrefixReturnsExpectedResult () {
291292
292- doWithConnection (connection -> connection .set ("_cache_key-1" .getBytes (Charset . forName ( "UTF-8" ) ), binarySample ));
293+ doWithConnection (connection -> connection .set ("_cache_key-1" .getBytes (StandardCharsets . UTF_8 ), binarySample ));
293294
294295 RedisCache cacheWithCustomPrefix = new RedisCache ("cache" , new DefaultRedisCacheWriter (connectionFactory ),
295296 RedisCacheConfiguration .defaultCacheConfig ().serializeValuesWith (SerializationPair .fromSerializer (serializer ))
@@ -307,18 +308,19 @@ public void cacheShouldAllowListKeyCacheKeysOfSimpleTypes() {
307308 Object key = SimpleKeyGenerator .generateKey (Collections .singletonList ("my-cache-key-in-a-list" ));
308309 cache .put (key , sample );
309310
310- Object target = cache .get (SimpleKeyGenerator .generateKey (Collections .singletonList ("my-cache-key-in-a-list" )));
311- assertThat (((ValueWrapper ) target ).get ()).isEqualTo (sample );
311+ ValueWrapper target = cache
312+ .get (SimpleKeyGenerator .generateKey (Collections .singletonList ("my-cache-key-in-a-list" )));
313+ assertThat (target .get ()).isEqualTo (sample );
312314 }
313315
314316 @ Test // DATAREDIS-1032
315317 public void cacheShouldAllowArrayKeyCacheKeysOfSimpleTypes () {
316318
317- Object key = SimpleKeyGenerator .generateKey (new String [] { "my-cache-key-in-an-array" } );
319+ Object key = SimpleKeyGenerator .generateKey ("my-cache-key-in-an-array" );
318320 cache .put (key , sample );
319321
320- Object target = cache .get (SimpleKeyGenerator .generateKey (new String [] { "my-cache-key-in-an-array" } ));
321- assertThat ((( ValueWrapper ) target ) .get ()).isEqualTo (sample );
322+ ValueWrapper target = cache .get (SimpleKeyGenerator .generateKey ("my-cache-key-in-an-array" ));
323+ assertThat (target .get ()).isEqualTo (sample );
322324 }
323325
324326 @ Test // DATAREDIS-1032
@@ -328,9 +330,9 @@ public void cacheShouldAllowListCacheKeysOfComplexTypes() {
328330 .generateKey (Collections .singletonList (new ComplexKey (sample .getFirstame (), sample .getBirthdate ())));
329331 cache .put (key , sample );
330332
331- Object target = cache .get (SimpleKeyGenerator
333+ ValueWrapper target = cache .get (SimpleKeyGenerator
332334 .generateKey (Collections .singletonList (new ComplexKey (sample .getFirstame (), sample .getBirthdate ()))));
333- assertThat ((( ValueWrapper ) target ) .get ()).isEqualTo (sample );
335+ assertThat (target .get ()).isEqualTo (sample );
334336 }
335337
336338 @ Test // DATAREDIS-1032
@@ -340,9 +342,9 @@ public void cacheShouldAllowMapCacheKeys() {
340342 .generateKey (Collections .singletonMap ("map-key" , new ComplexKey (sample .getFirstame (), sample .getBirthdate ())));
341343 cache .put (key , sample );
342344
343- Object target = cache .get (SimpleKeyGenerator
345+ ValueWrapper target = cache .get (SimpleKeyGenerator
344346 .generateKey (Collections .singletonMap ("map-key" , new ComplexKey (sample .getFirstame (), sample .getBirthdate ()))));
345- assertThat ((( ValueWrapper ) target ) .get ()).isEqualTo (sample );
347+ assertThat (target .get ()).isEqualTo (sample );
346348 }
347349
348350 @ Test // DATAREDIS-1032
0 commit comments