MigrationEventDao extends AbstractXpipeConsoleDAO { public MigrationEvent buildMigrationEvent(final long eventId) { List<MigrationEventTbl> eventDetails = queryHandler.handleQuery(new DalQuery<List<MigrationEventTbl>>() { @Override public List<MigrationEventTbl> doQuery() throws DalException { return migrationEventTblDao.findWithAllDetails(eventId, MigrationEventTblEntity.READSET_FULL_ALL); } }); return loadMigrationEvent(eventDetails); }  List<MigrationClusterModel> getMigrationCluster(final long eventId); MigrationEvent buildMigrationEvent(final long eventId); @DalTransaction MigrationEvent createMigrationEvent(MigrationRequest migrationRequest); List<Long> findAllUnfinished();  }
@Test @DirtiesContext public void testBuildMigrationEvent() { MigrationEvent event = migrationEventDao.buildMigrationEvent(2); Assert.assertNotNull(event); Assert.assertEquals(2, event.getMigrationCluster(2).getMigrationShards().size()); }
@Test @DirtiesContext public void testShardResult() { MigrationEvent event = migrationEventDao.buildMigrationEvent(2); MigrationCluster migrationCluster = event.getMigrationClusters().get(0); List<MigrationShard> migrationShards = migrationCluster.getMigrationShards(); migrationShards.forEach(migrationShard -> { ShardMigrationResult result = randomResult(); ((DefaultMigrationShard) migrationShard).updateShardMigrationResult(result); migrationShard.update(null, null); }); MigrationEvent eventNew = migrationEventDao.buildMigrationEvent(2); MigrationCluster migrationClusterNew = eventNew.getMigrationClusters().get(0); Assert.assertEquals(migrationCluster.clusterName(), migrationClusterNew.clusterName()); List<MigrationShard> migrationShardsNew = migrationClusterNew.getMigrationShards(); Assert.assertEquals(migrationShards.size(), migrationShardsNew.size()); for (int i = 0; i < migrationShards.size(); i++) { ShardMigrationResult result = migrationShards.get(i).getShardMigrationResult(); ShardMigrationResult resultNew = migrationShardsNew.get(i).getShardMigrationResult(); Assert.assertFalse(result == resultNew); Assert.assertEquals(result, resultNew); } }