@Test public void testGetOrCreateByLocaleCode() { Locale locale = dao.getOrCreateByLocaleCode(LocaleCode.EN_US); assertThat(locale).isNotNull().extracting("localeCode") .contains(LocaleCode.EN_US); }
public Locale getOrCreateByLocaleCode(LocaleCode localeCode) { Locale locale = getByLocaleCode(localeCode); if (locale == null) { ULocale uLocale = new ULocale(localeCode.getId()); locale = new Locale(localeCode, uLocale.getDisplayName()); locale = persist(locale); flush(); } return locale; }
LocaleDAO extends AbstractDAO<Locale> { public Locale getOrCreateByLocaleCode(LocaleCode localeCode) { Locale locale = getByLocaleCode(localeCode); if (locale == null) { ULocale uLocale = new ULocale(localeCode.getId()); locale = new Locale(localeCode, uLocale.getDisplayName()); locale = persist(locale); flush(); } return locale; } }
LocaleDAO extends AbstractDAO<Locale> { public Locale getOrCreateByLocaleCode(LocaleCode localeCode) { Locale locale = getByLocaleCode(localeCode); if (locale == null) { ULocale uLocale = new ULocale(localeCode.getId()); locale = new Locale(localeCode, uLocale.getDisplayName()); locale = persist(locale); flush(); } return locale; } @SuppressWarnings("unused")  LocaleDAO(); @VisibleForTesting  LocaleDAO(EntityManager entityManager); }
LocaleDAO extends AbstractDAO<Locale> { public Locale getOrCreateByLocaleCode(LocaleCode localeCode) { Locale locale = getByLocaleCode(localeCode); if (locale == null) { ULocale uLocale = new ULocale(localeCode.getId()); locale = new Locale(localeCode, uLocale.getDisplayName()); locale = persist(locale); flush(); } return locale; } @SuppressWarnings("unused")  LocaleDAO(); @VisibleForTesting  LocaleDAO(EntityManager entityManager); @Nullable Locale getByLocaleCode(LocaleCode localeCode); Locale getOrCreateByLocaleCode(LocaleCode localeCode); List<Locale> getSupportedLocales(); }
LocaleDAO extends AbstractDAO<Locale> { public Locale getOrCreateByLocaleCode(LocaleCode localeCode) { Locale locale = getByLocaleCode(localeCode); if (locale == null) { ULocale uLocale = new ULocale(localeCode.getId()); locale = new Locale(localeCode, uLocale.getDisplayName()); locale = persist(locale); flush(); } return locale; } @SuppressWarnings("unused")  LocaleDAO(); @VisibleForTesting  LocaleDAO(EntityManager entityManager); @Nullable Locale getByLocaleCode(LocaleCode localeCode); Locale getOrCreateByLocaleCode(LocaleCode localeCode); List<Locale> getSupportedLocales();  }