Ejemplo n.º 1
0
 @Test
 @Ignore("Cannot mock the log")
 public void canDoActionSucceedsWhenHasPeersThrowsException() throws Exception {
   setupGlusterMock(true, new VDS(), true);
   when(glusterUtil.getPeers(any(EngineSSHClient.class))).thenThrow(new RuntimeException());
   assertTrue(commandMock.canDoAction());
 }
Ejemplo n.º 2
0
  private void setupGlusterMock(boolean clusterHasServers, VDS upServer, boolean hasPeers)
      throws Exception {
    setupCommonMock(true);

    when(commandMock.createReturnValue()).thenCallRealMethod();
    when(commandMock.getReturnValue()).thenCallRealMethod();
    doCallRealMethod().when(commandMock).addCanDoActionMessage(any(EngineMessage.class));

    when(commandMock.getGlusterUtil()).thenReturn(glusterUtil);
    when(glusterUtil.getPeers(any(EngineSSHClient.class)))
        .thenReturn(hasPeers ? Collections.singleton(PEER_1) : Collections.<String>emptySet());

    when(commandMock.getGlusterDBUtils()).thenReturn(glusterDBUtils);

    when(clusterUtils.hasServers(any(Guid.class))).thenReturn(clusterHasServers);
    when(vdsDaoMock.getAllForVdsGroup(any(Guid.class)))
        .thenReturn(
            mockVdsInDb(clusterHasServers ? VDSStatus.Maintenance : VDSStatus.Initializing));
    when(clusterUtils.getUpServer(any(Guid.class))).thenReturn(upServer);

    // commandMock.log = log;
  }
Ejemplo n.º 3
0
 protected GlusterUtil getGlusterUtil() {
   return GlusterUtil.getInstance();
 }