@Test void testGetMessage() { doReturn("string 1 - nl").when(enPlusNl).getString(DUTCH); @SuppressWarnings("unchecked") Query<L10nString> query = mock(Query.class, RETURNS_SELF); when(dataService.query(L10N_STRING, L10nString.class)).thenReturn(query); when(query.eq(MSGID, "EN_PLUS_NL").findOne()).thenReturn(enPlusNl); assertEquals( "string 1 - nl", localizationService.resolveCodeWithoutArguments("EN_PLUS_NL", DUTCH)); }
@Override @RunAsSystem public String resolveCodeWithoutArguments(String code, Locale locale) { return Optional.ofNullable( dataService.query(L10N_STRING, L10nString.class).eq(MSGID, code).findOne()) .map(l10nString -> l10nString.getString(locale)) .orElse(null); }
LocalizationService implements MessageResolution { @Override @RunAsSystem public String resolveCodeWithoutArguments(String code, Locale locale) { return Optional.ofNullable( dataService.query(L10N_STRING, L10nString.class).eq(MSGID, code).findOne()) .map(l10nString -> l10nString.getString(locale)) .orElse(null); } }
LocalizationService implements MessageResolution { @Override @RunAsSystem public String resolveCodeWithoutArguments(String code, Locale locale) { return Optional.ofNullable( dataService.query(L10N_STRING, L10nString.class).eq(MSGID, code).findOne()) .map(l10nString -> l10nString.getString(locale)) .orElse(null); } LocalizationService(DataService dataService, L10nStringFactory l10nStringFactory); }
LocalizationService implements MessageResolution { @Override @RunAsSystem public String resolveCodeWithoutArguments(String code, Locale locale) { return Optional.ofNullable( dataService.query(L10N_STRING, L10nString.class).eq(MSGID, code).findOne()) .map(l10nString -> l10nString.getString(locale)) .orElse(null); } 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 { @Override @RunAsSystem public String resolveCodeWithoutArguments(String code, Locale locale) { return Optional.ofNullable( dataService.query(L10N_STRING, L10nString.class).eq(MSGID, code).findOne()) .map(l10nString -> l10nString.getString(locale)) .orElse(null); } 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);  }