/** * @see Daemon#executeScheduledTask(Task) */ @Test public void executeScheduledTask_shouldNotBeCalledFromOtherMethodsOtherThanTimerSchedulerTask() throws Throwable { try { Daemon.executeScheduledTask(new HelloWorldTask()); Assert.fail("Should not be here, an exception should have been thrown in the line above"); } catch (APIException e) { Assert.assertTrue(e.getMessage().startsWith(Context.getMessageSourceService().getMessage("Scheduler.timer.task.only", new Object[] { this.getClass().getName() }, null))); } }
/** * @see ImplementationIdValidator#validate(Object,Errors) */ @Test public void validate_shouldThrowAPIExceptionIfImplementationIdIsNUll() { try { new ImplementationIdValidator().validate(null, null); Assert.fail(); } catch (APIException e) { Assert.assertEquals(e.getMessage(), Context.getMessageSourceService().getMessage("ImplementationId.null")); } }
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public void changeOwnPassword(@RequestBody Map<String, String> body) { String oldPassword = body.get("oldPassword"); String newPassword = body.get("newPassword"); if (!Context.isAuthenticated()) { throw new APIAuthenticationException("Must be authenticated to change your own password"); } try { userService.changePassword(oldPassword, newPassword); } catch (APIException ex) { // this happens if they give the wrong oldPassword throw new ValidationException(ex.getMessage()); } }
if (!(e.getMessage() != null && e.getMessage().contains( "failed to validate with reason: " + Context.getMessageSourceService().getMessage("PatientIdentifier.error.checkDigitWithParameter", if (!(e.getMessage() != null && e.getMessage().contains( "failed to validate with reason: " + Context.getMessageSourceService().getMessage("PatientIdentifier.error.unallowedIdentifier",