@Test
@RedisAvailable
public void testZsetWithMapPayloadPojoAsSingleEntryHeaderKey() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.deletePresidents(jcf);
String key = "presidents";
RedisZSet<Map<President, Double>> redisZset =
new DefaultRedisZSet<Map<President, Double>>(key, this.initTemplate(jcf, new RedisTemplate<String, Map<President, Double>>()));
assertEquals(0, redisZset.size());
RedisTemplate<String, Map<President, Double>> template = this.initTemplate(jcf, new RedisTemplate<String, Map<President, Double>>());
RedisStoreWritingMessageHandler handler =
new RedisStoreWritingMessageHandler(template);
handler.setKey(key);
handler.setCollectionType(CollectionType.ZSET);
handler.setExtractPayloadElements(false);
handler.setBeanFactory(mock(BeanFactory.class));
handler.afterPropertiesSet();
Map<President, Double> presidents = new HashMap<President, Double>();
presidents.put(new President("John Adams"), 18D);
presidents.put(new President("Barack Obama"), 21D);
presidents.put(new President("Thomas Jefferson"), 19D);
Message<Map<President, Double>> message = MessageBuilder.withPayload(presidents).setHeader("redis_key", key).build();
handler.handleMessage(message);
assertEquals(1, redisZset.size());
this.deletePresidents(jcf);
}