|
15 | 15 | package com.dasburo.spring.cache.dynamo; |
16 | 16 |
|
17 | 17 | import com.dasburo.spring.cache.dynamo.helper.Address; |
| 18 | +import com.dasburo.spring.cache.dynamo.rootattribute.RootAttributeConfig; |
18 | 19 | import com.dasburo.spring.cache.dynamo.serializer.Jackson2JsonSerializer; |
19 | 20 | import org.junit.Assert; |
20 | 21 | import org.junit.Before; |
|
28 | 29 |
|
29 | 30 | import java.time.Duration; |
30 | 31 |
|
31 | | -import static org.mockito.Mockito.*; |
| 32 | +import static com.amazonaws.services.dynamodbv2.model.ScalarAttributeType.S; |
| 33 | +import static java.util.Collections.singletonList; |
| 34 | +import static org.mockito.Mockito.reset; |
| 35 | +import static org.mockito.Mockito.spy; |
| 36 | +import static org.mockito.Mockito.times; |
| 37 | +import static org.mockito.Mockito.verify; |
32 | 38 |
|
33 | 39 | /** |
34 | 40 | * Unit tests for {@link DynamoCache}. |
@@ -292,4 +298,22 @@ public void getWithCallableShouldNotResolveValueIfPresent() { |
292 | 298 | Assert.assertNotNull(addressCache.get(key)); |
293 | 299 | Assert.assertEquals(addressCache.get(key).get(), address); |
294 | 300 | } |
| 301 | + |
| 302 | + @Test |
| 303 | + public void putWithRootAttributeConfigCanBeLoadedAgain() { |
| 304 | + final String key = "key"; |
| 305 | + |
| 306 | + Address address = new Address("someStreet", 1); |
| 307 | + DynamoCacheConfiguration config = DynamoCacheConfiguration.defaultCacheConfig(); |
| 308 | + config.setSerializer(new Jackson2JsonSerializer<>(Address.class)); |
| 309 | + config.setRootAttributes(singletonList(new RootAttributeConfig("street", S))); |
| 310 | + |
| 311 | + Cache addressCache = new DynamoCache(CACHE_NAME, writer, config); |
| 312 | + |
| 313 | + addressCache.put(key, address); |
| 314 | + |
| 315 | + Assert.assertNotNull(addressCache.get(key)); |
| 316 | + Assert.assertEquals(addressCache.get(key).get(), address); |
| 317 | + } |
| 318 | + |
295 | 319 | } |
0 commit comments