Search in sources :

Example 1 with GetAllPkgCategoriesRequest

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");
}
Also used : GetAllNaturalLanguagesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesResult) ObjectContext(org.apache.cayenne.ObjectContext) URL(java.net.URL) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) PkgCategory(org.haiku.haikudepotserver.dataobjects.PkgCategory) IntegrationTestSupportService(org.haiku.haikudepotserver.IntegrationTestSupportService) GetAllArchitecturesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllArchitecturesRequest) GetAllUserRatingStabilitiesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllUserRatingStabilitiesRequest) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) GetAllPkgCategoriesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesRequest) GetAllMessagesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllMessagesRequest) GetAllUserRatingStabilitiesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllUserRatingStabilitiesResult) Splitter(com.google.common.base.Splitter) TestConfig(org.haiku.haikudepotserver.config.TestConfig) GetAllMessagesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllMessagesResult) GetAllNaturalLanguagesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesRequest) GetAllArchitecturesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllArchitecturesResult) UserRatingStability(org.haiku.haikudepotserver.dataobjects.UserRatingStability) MalformedURLException(java.net.MalformedURLException) Assertions(org.fest.assertions.Assertions) NaturalLanguage(org.haiku.haikudepotserver.dataobjects.NaturalLanguage) Resource(javax.annotation.Resource) RuntimeInformationService(org.haiku.haikudepotserver.support.RuntimeInformationService) Test(org.junit.jupiter.api.Test) List(java.util.List) GetRuntimeInformationResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetRuntimeInformationResult) GetRuntimeInformationRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetRuntimeInformationRequest) GenerateFeedUrlRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GenerateFeedUrlRequest) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Optional(java.util.Optional) FeedService(org.haiku.haikudepotserver.feed.model.FeedService) GetAllPkgCategoriesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesResult) GetAllPkgCategoriesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesResult) PkgCategory(org.haiku.haikudepotserver.dataobjects.PkgCategory) GetAllPkgCategoriesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesRequest) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with GetAllPkgCategoriesRequest

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);
    }
}
Also used : GetAllPkgCategoriesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesResult) PkgCategory(org.haiku.haikudepotserver.dataobjects.PkgCategory) GetAllPkgCategoriesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesRequest) ObjectContext(org.apache.cayenne.ObjectContext) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectContext (org.apache.cayenne.ObjectContext)2 AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)2 GetAllPkgCategoriesRequest (org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesRequest)2 GetAllPkgCategoriesResult (org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllPkgCategoriesResult)2 PkgCategory (org.haiku.haikudepotserver.dataobjects.PkgCategory)2 Test (org.junit.jupiter.api.Test)2 Splitter (com.google.common.base.Splitter)1 ImmutableList (com.google.common.collect.ImmutableList)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Resource (javax.annotation.Resource)1 Assertions (org.fest.assertions.Assertions)1 IntegrationTestSupportService (org.haiku.haikudepotserver.IntegrationTestSupportService)1 GenerateFeedUrlRequest (org.haiku.haikudepotserver.api1.model.miscellaneous.GenerateFeedUrlRequest)1 GetAllArchitecturesRequest (org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllArchitecturesRequest)1 GetAllArchitecturesResult (org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllArchitecturesResult)1 GetAllMessagesRequest (org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllMessagesRequest)1