@Test void testGetMessages() { @SuppressWarnings("unchecked") Query<L10nString> query = mock(Query.class, RETURNS_SELF); when(dataService.query(L10N_STRING, L10nString.class)).thenReturn(query); when(query.eq(NAMESPACE, "test").findAll()).thenReturn(Stream.of(enPlusNl, nlOnly)); when(enPlusNl.getMessageID()).thenReturn("EN_PLUS_NL"); doReturn("string 1 - nl").when(enPlusNl).getString(DUTCH); when(nlOnly.getMessageID()).thenReturn("NL_ONLY"); doReturn("string 2 - nl").when(nlOnly).getString(DUTCH); assertEquals( of("EN_PLUS_NL", "string 1 - nl", "NL_ONLY", "string 2 - nl"), localizationService.getMessages("test", DUTCH)); }
@RunAsSystem public Map<String, String> getMessages(String namespace, Locale locale) { return getL10nStrings(namespace).stream() .filter(e -> e.getString(locale) != null) .collect(toMap(L10nString::getMessageID, e -> e.getString(locale))); }
LocalizationService implements MessageResolution { @RunAsSystem public Map<String, String> getMessages(String namespace, Locale locale) { return getL10nStrings(namespace).stream() .filter(e -> e.getString(locale) != null) .collect(toMap(L10nString::getMessageID, e -> e.getString(locale))); } }
LocalizationService implements MessageResolution { @RunAsSystem public Map<String, String> getMessages(String namespace, Locale locale) { return getL10nStrings(namespace).stream() .filter(e -> e.getString(locale) != null) .collect(toMap(L10nString::getMessageID, e -> e.getString(locale))); } LocalizationService(DataService dataService, L10nStringFactory l10nStringFactory); }
LocalizationService implements MessageResolution { @RunAsSystem public Map<String, String> getMessages(String namespace, Locale locale) { return getL10nStrings(namespace).stream() .filter(e -> e.getString(locale) != null) .collect(toMap(L10nString::getMessageID, e -> e.getString(locale))); } LocalizationService(DataService dataService, L10nStringFactory l10nStringFactory); @Override @RunAsSystem String resolveCodeWithoutArguments(String code, Locale locale); @RunAsSystem Map<String, String> getMessages(String namespace, Locale locale); List<String> getAllMessageIds(); Stream<L10nString> getExistingMessages(String namespace, Set<String> messageIds); @Transactional void addMissingMessageIds(String namespace, Set<String> messageIDs); @Transactional void deleteNamespace(String namespace); void store(Collection<L10nString> toUpdate, Collection<L10nString> toAdd); }
LocalizationService implements MessageResolution { @RunAsSystem public Map<String, String> getMessages(String namespace, Locale locale) { return getL10nStrings(namespace).stream() .filter(e -> e.getString(locale) != null) .collect(toMap(L10nString::getMessageID, e -> e.getString(locale))); } LocalizationService(DataService dataService, L10nStringFactory l10nStringFactory); @Override @RunAsSystem String resolveCodeWithoutArguments(String code, Locale locale); @RunAsSystem Map<String, String> getMessages(String namespace, Locale locale); List<String> getAllMessageIds(); Stream<L10nString> getExistingMessages(String namespace, Set<String> messageIds); @Transactional void addMissingMessageIds(String namespace, Set<String> messageIDs); @Transactional void deleteNamespace(String namespace); void store(Collection<L10nString> toUpdate, Collection<L10nString> toAdd);  }