Search in sources :

Example 1 with MigrationPublishState

use of com.ctrip.xpipe.redis.console.migration.status.migration.MigrationPublishState in project x-pipe by ctripcorp.

the class DefaultMigrationClusterTest2 method testUpdateStat3.

@Test(expected = ServerException.class)
public void testUpdateStat3() throws Exception {
    AtomicInteger counter = new AtomicInteger(1);
    when(clusterService.find(anyString())).thenReturn(clusterTbl);
    doAnswer(new Answer() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            int currentCounter = counter.getAndIncrement();
            if (currentCounter % 7 == 0) {
                clusterTbl.setStatus(((ClusterStatus) invocation.getArguments()[1]).toString());
            }
            return null;
        }
    }).when(clusterService).updateStatusById(anyLong(), any());
    migrationCluster.updateStat(new MigrationPublishState(migrationCluster));
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ClusterStatus(com.ctrip.xpipe.redis.console.migration.status.ClusterStatus) MigrationPublishState(com.ctrip.xpipe.redis.console.migration.status.migration.MigrationPublishState) Test(org.junit.Test)

Aggregations

ClusterStatus (com.ctrip.xpipe.redis.console.migration.status.ClusterStatus)1 MigrationPublishState (com.ctrip.xpipe.redis.console.migration.status.migration.MigrationPublishState)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.Test)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1