@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException { RunDiagnosticsResponse response = new RunDiagnosticsResponse(); try { final Map<String, String> answerMap = diagnosticsService.runDiagnosticsCommand(this); if (CollectionUtils.isNotEmpty(Collections.singleton(answerMap))) { response.setStdout(answerMap.get(ApiConstants.STDOUT)); response.setStderr(answerMap.get(ApiConstants.STDERR)); response.setExitCode(answerMap.get(ApiConstants.EXITCODE)); response.setObjectName("diagnostics"); response.setResponseName(getCommandName()); this.setResponseObject(response); } } catch (final ServerApiException e) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); } } }
responseString = e.getMessage(); s_logger.debug("Authentication failure: " + e.getMessage());
@Test public void testExecuteWithNullPassword() { ReflectionTestUtils.setField(createAccountCmd, "password", null); try { createAccountCmd.execute(); Assert.fail("should throw exception for a null password"); } catch (ServerApiException e) { Assert.assertEquals(ApiErrorCode.PARAM_ERROR, e.getErrorCode()); Assert.assertEquals("Empty passwords are not allowed", e.getMessage()); } Mockito.verify(accountService, Mockito.never()).createUserAccount(null, null, null, null, null, null, null, accountType, roleId, domainId, null, null, null, null); }
@Test public void testExecuteWithEmptyPassword() { ReflectionTestUtils.setField(createAccountCmd, "password", ""); try { createAccountCmd.execute(); Assert.fail("should throw exception for a empty password"); } catch (ServerApiException e) { Assert.assertEquals(ApiErrorCode.PARAM_ERROR, e.getErrorCode()); Assert.assertEquals("Empty passwords are not allowed", e.getMessage()); } Mockito.verify(accountService, Mockito.never()).createUserAccount(null, null, null, null, null, null, null, accountType, roleId, domainId, null, null, null, null); } }
@Test public void testExecuteWithNullPassword() { ReflectionTestUtils.setField(createUserCmd, "password", null); try { createUserCmd.execute(); Assert.fail("should throw exception for a null password"); } catch (ServerApiException e) { Assert.assertEquals(ApiErrorCode.PARAM_ERROR,e.getErrorCode()); Assert.assertEquals("Empty passwords are not allowed", e.getMessage()); } Mockito.verify(accountService, Mockito.never()).createUser(null, null, null, null, null, null, null, null, null); }
@Test public void testExecuteWithEmptyPassword() { ReflectionTestUtils.setField(createUserCmd, "password", ""); try { createUserCmd.execute(); Assert.fail("should throw exception for a empty password"); } catch (ServerApiException e) { Assert.assertEquals(ApiErrorCode.PARAM_ERROR,e.getErrorCode()); Assert.assertEquals("Empty passwords are not allowed", e.getMessage()); } Mockito.verify(accountService, Mockito.never()).createUser(null, null, null, null, null, null, null, null, null); } }