CollectionInitializerService implements
      ICollectionInitializerService { @Override @Transactional(readOnly = true) public String getInstanceId() { List<ServerInfoEntity> entities = serverInfoDao.findAll(); if (entities != null && entities.size() == 1) { ServerInfoEntity entity = entities.get(0); String instanceId = entity.getInstanceId(); if (!CommonUtil.isBlank(instanceId)) { logger.debug("Instance id of data collection in the serengeti server is:" + instanceId); return instanceId; } } 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 testGetInstanceId() { final String instanceId = CommonUtil.getUUID(); serverInfoDao = new MockUp<IServerInfoDAO>() { @Mock List<ServerInfoEntity> findAll() { List<ServerInfoEntity> serverInfos = new ArrayList<ServerInfoEntity>(); ServerInfoEntity serverInfo = new ServerInfoEntity(); serverInfo.setInstanceId(instanceId); serverInfos.add(serverInfo); return serverInfos; } }.getMockInstance(); collectionInitializerService.setServerInfoDao(serverInfoDao); assertEquals(collectionInitializerService.getInstanceId(), instanceId); }