Search in sources :

Example 1 with GetAllNaturalLanguagesResult

use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesResult 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);
    }
}
Also used : GetAllNaturalLanguagesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesRequest) ObjectContext(org.apache.cayenne.ObjectContext) NaturalLanguage(org.haiku.haikudepotserver.dataobjects.NaturalLanguage) GetAllNaturalLanguagesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesResult) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with GetAllNaturalLanguagesResult

use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesResult 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");
}
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) GetAllNaturalLanguagesRequest(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesRequest) NaturalLanguage(org.haiku.haikudepotserver.dataobjects.NaturalLanguage) GetAllNaturalLanguagesResult(org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesResult) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectContext (org.apache.cayenne.ObjectContext)2 AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)2 GetAllNaturalLanguagesRequest (org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesRequest)2 GetAllNaturalLanguagesResult (org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllNaturalLanguagesResult)2 NaturalLanguage (org.haiku.haikudepotserver.dataobjects.NaturalLanguage)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