use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl in project x-pipe by ctripcorp.
the class MigrationStatTest method prepareData.
private void prepareData() {
mockedMigrationCluster = (new MigrationClusterTbl()).setId(1).setEventId(1).setClusterId(1).setDestinationDcId(2).setStatus(MigrationStatus.Initiated.toString());
ClusterTbl clusterTbl = new ClusterTbl().setId(1).setClusterName("test-cluster").setActivedcId(1).setStatus(ClusterStatus.Lock.toString());
when(mockedClusterService.find(1)).thenReturn(clusterTbl);
List<ShardTbl> shards = new LinkedList<>();
shards.add((new ShardTbl()).setId(1).setClusterId(1).setShardName("test-shard"));
when(mockedShardService.findAllByClusterName("test-cluster")).thenReturn(shards);
List<DcTbl> dcs = new LinkedList<>();
dcs.add((new DcTbl()).setId(1).setDcName("ADC"));
dcs.add((new DcTbl()).setId(2).setDcName("BDC"));
when(mockedDcService.findClusterRelatedDc("test-cluster")).thenReturn(dcs);
when(mockedClusterService.find(anyString())).thenReturn(clusterTbl);
when(mockedClusterService.find(anyInt())).thenReturn(clusterTbl);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
clusterTbl.setStatus(((ClusterStatus) invocation.getArguments()[1]).toString());
return null;
}
}).when(mockedClusterService).updateStatusById(anyInt(), any());
}
use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl in project x-pipe by ctripcorp.
the class MigrationServiceTest method createTest.
@Test
@DirtiesContext
public void createTest() throws ComponentLookupException {
long eventId = migrationService.createMigrationEvent(createEventDemo(1, 2));
MigrationEventTbl result = migrationService.find(eventId);
MigrationClusterTbl result_cluster = migrationService.findMigrationCluster(eventId, 1);
ClusterTbl cluster = clusterService.find(1);
List<MigrationShardTbl> result_shards = migrationService.findMigrationShards(result_cluster.getId());
Assert.assertEquals(eventId, result.getId());
Assert.assertEquals("unit test", result.getOperator());
Assert.assertNotNull(result_cluster);
Assert.assertEquals(1, result_cluster.getClusterId());
Assert.assertEquals(2, result_cluster.getDestinationDcId());
Assert.assertEquals(MigrationStatus.Initiated.toString(), result_cluster.getStatus());
Assert.assertEquals(ClusterStatus.Lock.toString(), cluster.getStatus());
Assert.assertEquals(2, result_shards.size());
}
Aggregations