Search in sources :

Example 1 with Language

use of org.molgenis.data.i18n.model.Language in project molgenis by molgenis.

the class EmxMetaDataParser method toLanguage.

/**
 * Creates a language entity from a EMX entity describing a language
 *
 * @param emxLanguageEntity EMX language entity
 * @return language entity
 */
private Language toLanguage(Entity emxLanguageEntity) {
    Language language = languageFactory.create();
    language.setCode(emxLanguageEntity.getString(EMX_LANGUAGE_CODE));
    language.setName(emxLanguageEntity.getString(EMX_LANGUAGE_NAME));
    return language;
}
Also used : Language(org.molgenis.data.i18n.model.Language)

Example 2 with Language

use of org.molgenis.data.i18n.model.Language in project molgenis by molgenis.

the class LanguageRepositoryDecoratorTest method getMockLanguage.

private Language getMockLanguage(String languageCode) {
    Language language = mock(Language.class);
    doReturn(languageCode).when(language).getCode();
    return language;
}
Also used : Language(org.molgenis.data.i18n.model.Language)

Example 3 with Language

use of org.molgenis.data.i18n.model.Language in project molgenis by molgenis.

the class LanguageRepositoryDecoratorTest method testAddStreamExistingLanguages.

@Test
public void testAddStreamExistingLanguages() {
    Language language0 = getMockLanguage(LANGUAGE_CODE_EN);
    Language language1 = getMockLanguage(LANGUAGE_CODE_NL);
    Integer count = languageRepositoryDecorator.add(Stream.of(language0, language1));
    assertEquals(count, Integer.valueOf(2));
    verify(delegateRepository).add(language0);
    verify(delegateRepository).add(language1);
}
Also used : Language(org.molgenis.data.i18n.model.Language) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 4 with Language

use of org.molgenis.data.i18n.model.Language in project molgenis by molgenis.

the class LanguageRepositoryDecoratorTest method testAddStreamUnknownLanguage.

@Test(expectedExceptions = MolgenisDataException.class, expectedExceptionsMessageRegExp = MESSAGE_ADD_NOT_ALLOWED)
public void testAddStreamUnknownLanguage() {
    Language language = mock(Language.class);
    when(language.getCode()).thenReturn("unknownLanguage");
    languageRepositoryDecorator.add(Stream.of(language));
}
Also used : Language(org.molgenis.data.i18n.model.Language) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 5 with Language

use of org.molgenis.data.i18n.model.Language in project molgenis by molgenis.

the class EmxMetaDataParser method parseLanguages.

private void parseLanguages(Repository<Entity> emxLanguageRepo, IntermediateParseResults intermediateParseResults) {
    emxLanguageRepo.forEach(emxLanguageEntity -> {
        Language language = toLanguage(emxLanguageEntity);
        intermediateParseResults.addLanguage(language);
    });
}
Also used : Language(org.molgenis.data.i18n.model.Language)

Aggregations

Language (org.molgenis.data.i18n.model.Language)8 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)5 Test (org.testng.annotations.Test)5