use of org.drools.scenariosimulation.backend.model.Person in project drools by kiegroup.
the class RuleScenarioRunnerHelperTest method createExtractorFunctionTest.
@Test
public void createExtractorFunctionTest() {
String personName = "Test";
FactMappingValue factMappingValue = new FactMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, personName);
Function<Object, ValueWrapper> extractorFunction = runnerHelper.createExtractorFunction(expressionEvaluator, factMappingValue, simulation.getScesimModelDescriptor());
Person person = new Person();
person.setFirstName(personName);
assertTrue(extractorFunction.apply(person).isValid());
person.setFirstName("OtherString");
assertFalse(extractorFunction.apply(person).isValid());
Function<Object, ValueWrapper> extractorFunction1 = runnerHelper.createExtractorFunction(expressionEvaluator, new FactMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, null), simulation.getScesimModelDescriptor());
ValueWrapper nullValue = extractorFunction1.apply(new Person());
assertTrue(nullValue.isValid());
assertNull(nullValue.getValue());
}
use of org.drools.scenariosimulation.backend.model.Person in project drools by kiegroup.
the class RuleScenarioRunnerHelperTest method createObjectDirectMappingComplexType.
@SuppressWarnings("unchecked")
@Test
public void createObjectDirectMappingComplexType() {
Map<List<String>, Object> params = new HashMap<>();
Person directMappingComplexTypeValue = new Person();
directMappingComplexTypeValue.setFirstName("TestName");
params.put(emptyList(), directMappingComplexTypeValue);
params.put(singletonList("age"), 10);
ValueWrapper<Object> initialInstance = runnerHelper.getDirectMapping(params);
Object objectRaw = runnerHelper.createObject(initialInstance, Map.class.getCanonicalName(), params, this.getClass().getClassLoader());
assertTrue(objectRaw instanceof Person);
Person object = (Person) objectRaw;
assertEquals(10, object.getAge());
assertEquals("TestName", object.getFirstName());
}
Aggregations