@Test public void testCreateSuccess() { updateHostPasswordCmd._mgr = managementServer; updateHostPasswordCmd._resourceService = resourceService; updateHostPasswordCmd._responseGenerator = responseGenerator; try { Mockito.when(managementServer.updateHostPassword(updateHostPasswordCmd)).thenReturn(true); } catch (final Exception e) { fail("Received exception when success expected " + e.getMessage()); } try { updateHostPasswordCmd.execute(); } catch (final ServerApiException exception) { assertEquals("Failed to update config", exception.getDescription()); } assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost()); verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd); } }
@Override public void execute() { if (getClusterId() == null) { _mgr.updateHostPassword(this); _resourceService.updateHostPassword(this); } else { _mgr.updateClusterPassword(this); _resourceService.updateClusterPassword(this); } setResponseObject(new SuccessResponse(getCommandName())); } }
@Test public void testExecuteForNullResult() { updateHostPasswordCmd._mgr = managementServer; updateHostPasswordCmd._resourceService = resourceService; try { Mockito.when(managementServer.updateHostPassword(updateHostPasswordCmd)).thenReturn(false); } catch (final InvalidParameterValueException e) { fail(e.getMessage()); } catch (final IllegalArgumentException e) { fail(e.getMessage()); } try { updateHostPasswordCmd.execute(); } catch (final ServerApiException exception) { Assert.assertEquals("Failed to update config", exception.getDescription()); } assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost()); verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd); }
@Test public void testCreateSuccess() { updateHostPasswordCmd._mgr = managementServer; updateHostPasswordCmd._resourceService = resourceService; updateHostPasswordCmd._responseGenerator = responseGenerator; try { Mockito.when(managementServer.updateHostPassword(updateHostPasswordCmd)).thenReturn(true); } catch (final Exception e) { fail("Received exception when success expected " + e.getMessage()); } try { updateHostPasswordCmd.execute(); } catch (final ServerApiException exception) { assertEquals("Failed to update config", exception.getDescription()); } assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost()); verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd); } }
@Override public void execute() { if (getClusterId() == null) { _mgr.updateHostPassword(this); _resourceService.updateHostPassword(this); } else { _mgr.updateClusterPassword(this); _resourceService.updateClusterPassword(this); } setResponseObject(new SuccessResponse(getCommandName())); }
@Test public void testExecuteForNullResult() { updateHostPasswordCmd._mgr = managementServer; updateHostPasswordCmd._resourceService = resourceService; try { Mockito.when(managementServer.updateHostPassword(updateHostPasswordCmd)).thenReturn(false); } catch (final InvalidParameterValueException e) { fail(e.getMessage()); } catch (final IllegalArgumentException e) { fail(e.getMessage()); } try { updateHostPasswordCmd.execute(); } catch (final ServerApiException exception) { Assert.assertEquals("Failed to update config", exception.getDescription()); } assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost()); verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd); }