CollectionInitializerService implements
      ICollectionInitializerService { @Override @Transactional(readOnly = true) public Date getDeployTime() { List<ServerInfoEntity> entities = serverInfoDao.findAll(); if (entities != null && entities.size() == 1) { ServerInfoEntity entity = entities.get(0); Timestamp timestamp = entity.getDeployTime(); if (timestamp != null) { String timestampStr = df.format(timestamp); logger.debug("deploy time of serengeti is " + timestampStr); try { return df.parse(timestampStr); } catch (ParseException e) { logger.warn("Parse timestamp failed: " + e.getLocalizedMessage()); } } } return null; }  @Override @Transactional @RetryTransaction(2) void setDeployTime(Date date); @Override @Transactional(readOnly = true) Date getDeployTime(); @Override @Transactional @RetryTransaction(2) void generateInstanceId(); @Override @Transactional(readOnly = true) String getInstanceId(); IServerInfoDAO getServerInfoDao(); @Autowired void setServerInfoDao(IServerInfoDAO serverInfoDao);  }
@Test(groups = { "TestCollectionInitializerService" }) public void testGetDeployTime() { serverInfoDao = new MockUp<IServerInfoDAO>() { @Mock List<ServerInfoEntity> findAll() { List<ServerInfoEntity> serverInfos = new ArrayList<ServerInfoEntity>(); ServerInfoEntity serverInfo = new ServerInfoEntity(); serverInfo.setDeployTime(Timestamp.valueOf(DEPLOY_TIME)); serverInfos.add(serverInfo); return serverInfos; } }.getMockInstance(); collectionInitializerService.setServerInfoDao(serverInfoDao); Date date = collectionInitializerService.getDeployTime(); assertEquals(df.format(date), DEPLOY_TIME); }