MigrationEventDao extends AbstractXpipeConsoleDAO { public List<MigrationClusterModel> getMigrationCluster(final long eventId) { List<MigrationClusterModel> res = new LinkedList<>(); Map<Long, String> dcMap = dcService.dcNameMap(); List<MigrationClusterTbl> migrationClusterTbls = queryHandler.handleQuery(new DalQuery<List<MigrationClusterTbl>>() { @Override public List<MigrationClusterTbl> doQuery() throws DalException { return migrationClusterTblDao.findByEventId(eventId, MigrationClusterTblEntity.READSET_FULL_ALL); } }); for(MigrationClusterTbl migrationClusterTbl : migrationClusterTbls) { MigrationClusterModel model = new MigrationClusterModel(); ClusterTbl cluster = migrationClusterTbl.getCluster(); model.setMigrationCluster(new MigrationClusterInfo(cluster.getClusterName(), dcMap, migrationClusterTbl)); List<MigrationShardTbl> migrationShardTbls = queryHandler.handleQuery(new DalQuery<List<MigrationShardTbl>>() { @Override public List<MigrationShardTbl> doQuery() throws DalException { return migrationShardTblDao.findByMigrationClusterId(migrationClusterTbl.getId(), MigrationShardTblEntity.READSET_FULL_ALL); } }); for(MigrationShardTbl migrationShardTbl : migrationShardTbls) { MigrationShardModel shardModel = new MigrationShardModel(); shardModel.setMigrationShard(migrationShardTbl); model.addMigrationShard(shardModel); } res.add(model); } return res; }  List<MigrationClusterModel> getMigrationCluster(final long eventId); MigrationEvent buildMigrationEvent(final long eventId); @DalTransaction MigrationEvent createMigrationEvent(MigrationRequest migrationRequest); List<Long> findAllUnfinished();  }
@Test public void testGetMigrationCluster(){ List<MigrationClusterModel> migrationCluster = migrationEventDao.getMigrationCluster(2); Assert.assertEquals(1, migrationCluster.size()); MigrationClusterInfo clusterInfo = migrationCluster.iterator().next().getMigrationCluster(); logger.info("{}", clusterInfo); Assert.assertEquals("cluster2", clusterInfo.getClusterName()); Assert.assertEquals(dcNames[0], clusterInfo.getSourceDcName()); Assert.assertEquals(dcNames[1], clusterInfo.getDestinationDcName()); Assert.assertEquals("Checking", clusterInfo.getStatus()); Assert.assertEquals(2, clusterInfo.getClusterId()); Assert.assertEquals(2, clusterInfo.getMigrationEventId()); Assert.assertEquals("", clusterInfo.getPublishInfo()); }