PeerMasterChooseCommand extends AbstractMasterChooseCommand { @Override public RedisMeta choose() { return multiDcService.getPeerMaster(dcId, clusterId, shardId); } PeerMasterChooseCommand(String dcId, String clusterId, String shardId, MultiDcService multiDcService); @Override RedisMeta choose();  }
@Test public void testChoose() { RedisMeta redisMeta = new RedisMeta().setIp("127.0.0.1").setPort(6379).setGid(1L); Mockito.when(multiDcService.getPeerMaster(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(redisMeta); RedisMeta result = chooseCommand.choose(); Assert.assertEquals(redisMeta, result); Mockito.verify(multiDcService, times(1)).getPeerMaster(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()); }