### Question:
CDKeyManager extends AbstractMongoManager { public String generateCDKey(String cdKeyPojoId) { Jedis jedis = JedisFactory.getJedisDB(); String cdkey = String.valueOf((int)(MathUtil.nextDouble()*100000000)); while ( jedis.hexists(REDIS_CDKEY, cdkey) ) { cdkey = String.valueOf((int)(MathUtil.nextDouble()*100000000)); } int diff = 8 - cdkey.length(); if ( diff>0 ) { cdkey = StringUtil.concat(PADDING[diff-1], cdkey); } jedis.hset(REDIS_CDKEY, cdkey, cdKeyPojoId); return cdkey; } CDKeyManager(); static CDKeyManager getInstance(); void reload(); Collection<CDKeyPojo> getCDKeys(); CDKeyPojo getCDKeyById(String id); void addCDKey(CDKeyPojo cdkey); boolean takeCDKeyReward(User user, String cdkey); String generateCDKey(String cdKeyPojoId); boolean exportCDKey(String fileName, String pojoId, int count); int importCDKey(String fileName); static final String REDIS_CDKEY; }### Answer:
@Test public void testGenerateCDKey() throws Exception { CDKeyManager manager = CDKeyManager.getInstance(); int count = 100; String cdId = "1"; ArrayList<String> cdkeys = new ArrayList<String>(count); for ( int i=0; i<count; i++ ) { String cdkey = manager.generateCDKey(cdId); cdkeys.add(cdkey); } for ( String cdkey : cdkeys ) { System.out.println(cdkey); } }