Search in sources :

Example 1 with AllPropertiesMessageSource

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);
}
Also used : AllPropertiesMessageSource(org.molgenis.i18n.properties.AllPropertiesMessageSource)

Example 2 with 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");
}
Also used : AllPropertiesMessageSource(org.molgenis.i18n.properties.AllPropertiesMessageSource) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with AllPropertiesMessageSource

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");
}
Also used : AllPropertiesMessageSource(org.molgenis.i18n.properties.AllPropertiesMessageSource) ObjectError(org.springframework.validation.ObjectError) DefaultMessageSourceResolvable(org.springframework.context.support.DefaultMessageSourceResolvable) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) FieldError(org.springframework.validation.FieldError) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with AllPropertiesMessageSource

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");
}
Also used : AllPropertiesMessageSource(org.molgenis.i18n.properties.AllPropertiesMessageSource) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with AllPropertiesMessageSource

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);
}
Also used : NegotiatorEntityConfig(org.molgenis.dataexplorer.negotiator.config.NegotiatorEntityConfig) AllPropertiesMessageSource(org.molgenis.i18n.properties.AllPropertiesMessageSource) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

AllPropertiesMessageSource (org.molgenis.i18n.properties.AllPropertiesMessageSource)5 BeforeMethod (org.testng.annotations.BeforeMethod)3 NegotiatorEntityConfig (org.molgenis.dataexplorer.negotiator.config.NegotiatorEntityConfig)1 DefaultMessageSourceResolvable (org.springframework.context.support.DefaultMessageSourceResolvable)1 ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)1 FieldError (org.springframework.validation.FieldError)1 ObjectError (org.springframework.validation.ObjectError)1 BeforeClass (org.testng.annotations.BeforeClass)1