@Test public void testGetSupportedLocales() { List<Locale> locales = ImmutableList.of(new Locale(LocaleCode.EN_US, "English"), new Locale(LocaleCode.DE, "German")); List<org.zanata.magpie.api.dto.Locale> expectedLocales = ImmutableList.of( new org.zanata.magpie.api.dto.Locale("en-us", "English"), new org.zanata.magpie.api.dto.Locale("de", "German")); when(localeDAO.getSupportedLocales()).thenReturn(locales); Response response = languagesResource.getSupportedLanguages(); assertThat(response.getStatus()) .isEqualTo(Response.Status.OK.getStatusCode()); @SuppressWarnings("unchecked") List<org.zanata.magpie.api.dto.Locale> dtos = (List)response.getEntity(); assertThat(dtos).isNotNull().hasSize(locales.size()); assertThat(dtos.containsAll(expectedLocales)).isTrue(); }
@Override public Response getSupportedLanguages() { List<Locale> locales = localeDAO.getSupportedLocales(); List<org.zanata.magpie.api.dto.Locale> dtos = locales.stream() .map(locale -> new org.zanata.magpie.api.dto.Locale( locale.getLocaleCode().getId(), locale.getName())) .collect(Collectors.toList()); return Response.ok().entity(dtos).build(); }
LanguagesResourceImpl implements LanguagesResource { @Override public Response getSupportedLanguages() { List<Locale> locales = localeDAO.getSupportedLocales(); List<org.zanata.magpie.api.dto.Locale> dtos = locales.stream() .map(locale -> new org.zanata.magpie.api.dto.Locale( locale.getLocaleCode().getId(), locale.getName())) .collect(Collectors.toList()); return Response.ok().entity(dtos).build(); } }
LanguagesResourceImpl implements LanguagesResource { @Override public Response getSupportedLanguages() { List<Locale> locales = localeDAO.getSupportedLocales(); List<org.zanata.magpie.api.dto.Locale> dtos = locales.stream() .map(locale -> new org.zanata.magpie.api.dto.Locale( locale.getLocaleCode().getId(), locale.getName())) .collect(Collectors.toList()); return Response.ok().entity(dtos).build(); } @SuppressWarnings("unused")  LanguagesResourceImpl(); @Inject  LanguagesResourceImpl(LocaleDAO localeDAO); }
LanguagesResourceImpl implements LanguagesResource { @Override public Response getSupportedLanguages() { List<Locale> locales = localeDAO.getSupportedLocales(); List<org.zanata.magpie.api.dto.Locale> dtos = locales.stream() .map(locale -> new org.zanata.magpie.api.dto.Locale( locale.getLocaleCode().getId(), locale.getName())) .collect(Collectors.toList()); return Response.ok().entity(dtos).build(); } @SuppressWarnings("unused")  LanguagesResourceImpl(); @Inject  LanguagesResourceImpl(LocaleDAO localeDAO); @Override Response getSupportedLanguages(); }
LanguagesResourceImpl implements LanguagesResource { @Override public Response getSupportedLanguages() { List<Locale> locales = localeDAO.getSupportedLocales(); List<org.zanata.magpie.api.dto.Locale> dtos = locales.stream() .map(locale -> new org.zanata.magpie.api.dto.Locale( locale.getLocaleCode().getId(), locale.getName())) .collect(Collectors.toList()); return Response.ok().entity(dtos).build(); } @SuppressWarnings("unused")  LanguagesResourceImpl(); @Inject  LanguagesResourceImpl(LocaleDAO localeDAO); @Override Response getSupportedLanguages();  }