### Question:
DefaultAvatarEditor extends PropertyEditorSupport { @Override public void setAsText(String text) { try { byte[] avatarAsByte = base64Wrapper.decodeB64Bytes(text); imageService.validateImageSize(avatarAsByte); imageService.validateImageFormat(avatarAsByte); setValue(text); } catch (ImageProcessException e) { setValue(base64Wrapper.encodeB64Bytes(imageService.getDefaultImage())); } } DefaultAvatarEditor(ImageService imageService); @Override void setAsText(String text);  }### Answer:
@Test public void userSetIncorrectAvatarShouldGetDefaultAvatar() throws ImageProcessException, NotFoundException { byte[] avatar = new byte[10]; doThrow(new ImageFormatException("test")).when(imageService).validateImageFormat(any(byte[].class)); doThrow(new ImageSizeException(1)).when(imageService).validateImageSize(any(byte[].class)); defaultAvatarEditor.setAsText(String.valueOf(avatar)); verify(imageService, times(1)).getDefaultImage(); }
@Test public void userSetValidAvatarShouldGetSettedAvatar() throws ImageProcessException, NotFoundException { byte[] avatar = new byte[10]; defaultAvatarEditor.setAsText(String.valueOf(avatar)); verify(imageService, never()).getDefaultImage(); }