use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class JsMagmaScriptEvaluatorTest method mapSimple.
@Test
public void mapSimple() {
Entity gender = new DynamicEntity(genderEntityType);
gender.set("id", "m");
gender.set("label", "Male");
Entity person = new DynamicEntity(personGenderEntityType);
person.set("gender", gender);
Object result = jsMagmaScriptEvaluator.eval("$('gender').map({'m':'Male'}).value()", person, 3);
assertEquals(result.toString(), "Male");
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class JsMagmaScriptEvaluatorTest method testValueForXrefDefaultDepth.
@Test
public void testValueForXrefDefaultDepth() {
Entity gender = new DynamicEntity(genderEntityType);
gender.set("id", "1");
gender.set("label", "male");
Entity person = new DynamicEntity(personGenderEntityType);
person.set("gender", gender);
Object result = jsMagmaScriptEvaluator.eval("$('gender.label').value()", person);
assertEquals(result.toString(), "undefined");
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class JsMagmaScriptEvaluatorTest method testUnitConversion.
@Test
public void testUnitConversion() {
Entity person = new DynamicEntity(personWeightEntityType);
person.set("weight", 82);
Object weight = jsMagmaScriptEvaluator.eval("$('weight').unit('kg').toUnit('poundmass').value()", person, 3);
assertEquals(weight, 180.7790549915996);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class JsMagmaScriptEvaluatorTest method testIsNull.
@Test
public void testIsNull() {
Entity person0 = new DynamicEntity(personWeightEntityType);
person0.set("weight", null);
String script = "$('weight').isNull().value()";
Object result = jsMagmaScriptEvaluator.eval(script, person0, 3);
assertEquals(result, true);
Entity person1 = new DynamicEntity(personWeightEntityType);
person1.set("weight", 99);
result = jsMagmaScriptEvaluator.eval(script, person1, 3);
assertEquals(result, false);
}
use of org.molgenis.data.support.DynamicEntity in project molgenis by molgenis.
the class JsMagmaScriptEvaluatorTest method testNot.
@Test
public void testNot() {
Entity person0 = new DynamicEntity(personWeightEntityType);
person0.set("weight", null);
String script = "$('weight').isNull().not().value()";
Object result = jsMagmaScriptEvaluator.eval(script, person0, 3);
assertEquals(result, false);
Entity person1 = new DynamicEntity(personWeightEntityType);
person1.set("weight", 99);
result = jsMagmaScriptEvaluator.eval(script, person1, 3);
assertEquals(result, true);
}
Aggregations