use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesRequest in project haikudepotserver by haiku.
the class MiscelaneousApiIT method testGetAllPkgCategories_de.
/**
* <p>If the client asks for all of the categories with a natural language code then they will be returned
* the localized name of the category where possible. This tests this with German as German translations
* are known to be present.</p>
*/
@Test
public void testGetAllPkgCategories_de() {
GetAllPkgCategoriesRequest request = new GetAllPkgCategoriesRequest();
request.naturalLanguageCode = NaturalLanguage.CODE_GERMAN;
// ------------------------------------
GetAllPkgCategoriesResult result = miscellaneousApi.getAllPkgCategories(request);
// ------------------------------------
Optional<GetAllPkgCategoriesResult.PkgCategory> pkgCategoryOptional = result.pkgCategories.stream().filter(pks -> pks.code.equals("education")).findFirst();
Assertions.assertThat(pkgCategoryOptional.isPresent()).isTrue();
Assertions.assertThat(pkgCategoryOptional.get().name).isEqualTo("Bildung");
}
use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesRequest in project haikudepotserver by haiku.
the class MiscelaneousApiIT method testGetAllPkgCategories.
@Test
public void testGetAllPkgCategories() {
// ------------------------------------
GetAllPkgCategoriesResult result = miscellaneousApi.getAllPkgCategories(new GetAllPkgCategoriesRequest());
// ------------------------------------
ObjectContext objectContext = serverRuntime.newContext();
List<PkgCategory> pkgCategories = PkgCategory.getAll(objectContext);
Assertions.assertThat(pkgCategories.size()).isEqualTo(result.pkgCategories.size());
for (int i = 0; i < pkgCategories.size(); i++) {
PkgCategory pkgCategory = pkgCategories.get(i);
GetAllPkgCategoriesResult.PkgCategory apiPkgCategory = result.pkgCategories.get(i);
Assertions.assertThat(pkgCategory.getName()).isEqualTo(apiPkgCategory.name);
Assertions.assertThat(pkgCategory.getCode()).isEqualTo(apiPkgCategory.code);
}
}
Aggregations