use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesRequest in project haikudepotserver by haiku.
the class MiscelaneousApiIT method testGetAllNaturalLanguages.
@Test
public void testGetAllNaturalLanguages() {
// ------------------------------------
GetAllNaturalLanguagesResult result = miscellaneousApi.getAllNaturalLanguages(new GetAllNaturalLanguagesRequest());
// ------------------------------------
ObjectContext objectContext = serverRuntime.newContext();
List<NaturalLanguage> naturalLanguages = NaturalLanguage.getAll(objectContext);
Assertions.assertThat(naturalLanguages.size()).isEqualTo(result.naturalLanguages.size());
for (int i = 0; i < naturalLanguages.size(); i++) {
NaturalLanguage naturalLanguage = naturalLanguages.get(i);
GetAllNaturalLanguagesResult.NaturalLanguage apiNaturalLanguage = result.naturalLanguages.get(i);
Assertions.assertThat(naturalLanguage.getName()).isEqualTo(apiNaturalLanguage.name);
Assertions.assertThat(naturalLanguage.getCode()).isEqualTo(apiNaturalLanguage.code);
}
}
use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesRequest in project haikudepotserver by haiku.
the class MiscelaneousApiIT method testGetAllNaturalLanguages_de.
/**
* <p>It is possible to request the natural languages with a natural language code. In this case, the
* results will localize the names as opposed to using those onces directly from the database.</p>
*/
@Test
public void testGetAllNaturalLanguages_de() {
GetAllNaturalLanguagesRequest request = new GetAllNaturalLanguagesRequest();
request.naturalLanguageCode = NaturalLanguage.CODE_GERMAN;
// ------------------------------------
GetAllNaturalLanguagesResult result = miscellaneousApi.getAllNaturalLanguages(request);
// ------------------------------------
Optional<GetAllNaturalLanguagesResult.NaturalLanguage> naturalLanguageOptional = result.naturalLanguages.stream().filter(nl -> nl.code.equalsIgnoreCase("es")).findFirst();
Assertions.assertThat(naturalLanguageOptional.isPresent()).isTrue();
Assertions.assertThat(naturalLanguageOptional.get().name).isEqualTo("Espa\u00F1ol");
}
Aggregations