Also trim monolingual text values.

This commit is contained in:
Antonin Delpeuch 2018-11-01 15:33:26 +00:00
parent 8b4cf84bfd
commit 604666ed6a
2 changed files with 7 additions and 1 deletions

View File

@ -53,7 +53,7 @@ public class WbMonolingualExpr implements WbExpression<MonolingualTextValue> {
String text = getValueExpr().evaluate(ctxt).getString();
try {
String lang = getLanguageExpr().evaluate(ctxt);
return Datamodel.makeMonolingualTextValue(text, lang);
return Datamodel.makeMonolingualTextValue(text.trim(), lang);
} catch (SkipSchemaExpressionException e) {
QAWarning warning = new QAWarning("monolingual-text-without-language", null, QAWarning.Severity.WARNING, 1);

View File

@ -43,6 +43,12 @@ public class WbMonolingualExprTest extends WbExpressionTest<MonolingualTextValue
setRow("en", "hello");
evaluatesTo(Datamodel.makeMonolingualTextValue("hello", "en"), expr);
}
@Test
public void testTrim() {
setRow("en", " hello ");
evaluatesTo(Datamodel.makeMonolingualTextValue("hello", "en"), expr);
}
@Test
public void testInvalidLanguageCode() {