### Question:
MarshallingResponsePopup { String displayableValue(MarshallingMessage message) { if (StringUtils.nonEmpty(message.getMessageKey())) { final List<?> arguments = Optional.ofNullable(message.getMessageArguments()).orElse(Collections.emptyList()); String translation = translationService.getValue(message.getMessageKey(), arguments.toArray(new Object[0])); if (!erraiDefaultValue(message.getMessageKey()).equals(translation)) { return translation; } } return message.getMessage(); } @Inject  MarshallingResponsePopup(View view, ClientTranslationService translationService); void show(String title,
                     String notificationMessage, InlineNotification.InlineNotificationType notificationType,
                     List<MarshallingMessage> messages,
                     String okCommandLabel, Command okCommand); void show(String title,
                     String notificationMessage, InlineNotification.InlineNotificationType notificationType,
                     List<MarshallingMessage> messages,
                     String okCommandLabel);  }### Answer:
@Test public void testDisplayableValueForViolation() { prepareErrorTranslations(); assertEquals(ERROR_TRANSLATION, popup.displayableValue(Violation.Type.ERROR)); assertEquals(WARNING_TRANSLATION, popup.displayableValue(Violation.Type.WARNING)); assertEquals(INFO_TRANSLATION, popup.displayableValue(Violation.Type.INFO)); assertEquals(MESSAGE_TRANSLATION, popup.displayableValue((Violation.Type) null)); }
@Test public void testDisplayableValueForMessageWithTranslation() { List<?> messageArguments = new ArrayList<>(); MarshallingMessage message = new MarshallingMessage.MarshallingMessageBuilder() .messageKey(MESSAGE_KEY) .message(MESSAGE) .messageArguments(messageArguments) .build(); when(translationService.getValue(MESSAGE_KEY, toArray(messageArguments))).thenReturn(MESSAGE_TRANSLATION); assertEquals(MESSAGE_TRANSLATION, popup.displayableValue(message)); }
@Test public void testDisplayableValueForMessageWithoutTranslation() { List<?> messageArguments = new ArrayList<>(); MarshallingMessage message = new MarshallingMessage.MarshallingMessageBuilder() .messageKey(MESSAGE_KEY) .message(MESSAGE) .messageArguments(messageArguments) .build(); when(translationService.getValue(MESSAGE_KEY, toArray(messageArguments))) .thenReturn("!!!" + MESSAGE_KEY + "!!!"); assertEquals(MESSAGE, popup.displayableValue(message)); }
@Test public void testDisplayableValueForMessageWithoutMessageKey() { MarshallingMessage message = new MarshallingMessage.MarshallingMessageBuilder() .messageKey(null) .message(MESSAGE) .build(); assertEquals(MESSAGE, popup.displayableValue(message)); }