@Test public void testChangeUserPasswordCorrect() { String currentUserPassword = editUserProfileDto.getCurrentUserPassword(); Mockito.when(encryptionService.encryptPassword(currentUserPassword)) .thenReturn(currentUserPassword); boolean isValid = validator.isValid(editUserProfileDto, validatorContext); Assert.assertEquals(isValid, true, "The old password is correct, but the check fails."); }