use of org.molgenis.i18n.properties.AllPropertiesMessageSource in project molgenis by molgenis.
the class I18nPopulator method populateL10nStrings.
/**
* Populates dataService with localization strings from property files on the classpath.
* <p>
* N.B. If you want to add a namespace with a localization resourcebundle, you need to
* add a PropertiesMessageSource bean to the spring context for that namespace.
*/
public void populateL10nStrings() {
AllPropertiesMessageSource allPropertiesMessageSource = new AllPropertiesMessageSource();
String[] namespaces = localizationMessageSources.stream().map(PropertiesMessageSource::getNamespace).toArray(String[]::new);
allPropertiesMessageSource.addMolgenisNamespaces(namespaces);
localizationPopulator.populateLocalizationStrings(allPropertiesMessageSource);
}
use of org.molgenis.i18n.properties.AllPropertiesMessageSource in project molgenis by molgenis.
the class AllPropertiesMessageSourceTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
propertiesMessageSource = new AllPropertiesMessageSource();
propertiesMessageSource.addMolgenisNamespaces("test");
}
use of org.molgenis.i18n.properties.AllPropertiesMessageSource in project molgenis by molgenis.
the class SpringExceptionHandlerTest method beforeClass.
@BeforeClass
public void beforeClass() {
AllPropertiesMessageSource molgenisLocalizationMessages = new AllPropertiesMessageSource();
molgenisLocalizationMessages.addMolgenisNamespaces("web");
ResourceBundleMessageSource hibernateValidationMessages = new ResourceBundleMessageSource();
hibernateValidationMessages.addBasenames("org.hibernate.validator.ValidationMessages");
molgenisLocalizationMessages.setParentMessageSource(hibernateValidationMessages);
MessageSourceHolder.setMessageSource(molgenisLocalizationMessages);
globalError = new ObjectError("entityCollectionRequestV2", new String[] { "TwoFieldsSet" }, new Object[] { 1 }, "must have two fields set");
fieldError = new FieldError("entityCollectionRequestV2", "num", -10, false, new String[] { "Min.entityCollectionRequestV2.num", "Min.num", "Min.int", "Min" }, new Object[] { new DefaultMessageSourceResolvable(new String[] { "entityCollectionRequestV2.num", "num" }, null, "num"), 0 }, "must be greater than or equal to 0");
}
use of org.molgenis.i18n.properties.AllPropertiesMessageSource in project molgenis by molgenis.
the class LocalizationPopulatorTest method beforeMethod.
@BeforeMethod
public void beforeMethod() {
localizationPopulator = new LocalizationPopulator(localizationService, l10nStringFactory);
allPropertiesMessageSource = new AllPropertiesMessageSource();
allPropertiesMessageSource.addMolgenisNamespaces("test");
}
use of org.molgenis.i18n.properties.AllPropertiesMessageSource in project molgenis by molgenis.
the class NegotiatorControllerTest method beforeMethod.
@BeforeMethod
public void beforeMethod() {
initMocks(this);
/* Negotiator config mock */
Query<NegotiatorEntityConfig> query = new QueryImpl<NegotiatorEntityConfig>().eq(NegotiatorEntityConfigMeta.ENTITY, "molgenis_id_1");
when(dataService.findOne(NegotiatorEntityConfigMeta.NEGOTIATORENTITYCONFIG, query, NegotiatorEntityConfig.class)).thenReturn(negotiatorEntityConfig);
when(collectionAttr.getName()).thenReturn("collectionAttr");
when(collectionAttr.getDataType()).thenReturn(AttributeType.STRING);
doReturn(collectionAttr).when(negotiatorEntityConfig).getEntity(COLLECTION_ID, Attribute.class);
when(biobackAttr.getName()).thenReturn("biobackAttr");
when(biobackAttr.getDataType()).thenReturn(AttributeType.STRING);
doReturn(biobackAttr).when(negotiatorEntityConfig).getEntity(BIOBANK_ID, Attribute.class);
when(negotiatorEntityConfig.getString(ENABLED_EXPRESSION)).thenReturn("$(enabled).value()");
when(negotiatorEntityConfig.getNegotiatorConfig()).thenReturn(negotiatorConfig);
/* get EntityCollection mock */
when(entityType.getId()).thenReturn("molgenis_id_1");
when(dataService.getEntityType("molgenis_id_1")).thenReturn(entityType);
when(queryRsql.createQuery(entityType)).thenReturn(molgenisQuery);
when(rsqlQueryConverter.convert("*=q=MOLGENIS")).thenReturn(queryRsql);
LocaleContextHolder.setLocale(Locale.ENGLISH);
AllPropertiesMessageSource messageSource = new AllPropertiesMessageSource();
messageSource.addMolgenisNamespaces("dataexplorer");
negotiatorController = new NegotiatorController(restTemplate, permissionService, dataService, rsqlQueryConverter, jsMagmaScriptEvaluator, messageSource);
}
Aggregations