PlannerValidationMessageTranslator implements ValidationMessageTranslator { @Override public ValidationMessage translate(final ValidationMessage messageToTranslate) { String translationKey = MESSAGE_CLASS_KEY_MAPPING.get(messageToTranslate.getClass().getName()); if (translationKey == null) { throw new IllegalStateException("No translation found for message " + messageToTranslate); } return getMessageTranslation(messageToTranslate, translationKey); } @Inject  PlannerValidationMessageTranslator(final TranslationService translationService); @Override boolean accept(final ValidationMessage message); @Override ValidationMessage translate(final ValidationMessage messageToTranslate);  }
@Test public void translateSupported() { when(translationService.getTranslation(anyString())).thenReturn("Test translation"); ValidationMessage translatedMessage = translator.translate(new PlanningSolutionToBeDuplicatedMessage(Level.ERROR)); assertEquals("Test translation", translatedMessage.getText()); }
@Test(expected = IllegalStateException.class) public void translateUnsupported() { assertNotNull(translator.translate(new UnsupportedMessage())); }