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;
}
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;
}
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);
}
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));
}
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);
});
}
Aggregations