use of org.drools.workbench.models.testscenarios.shared.FactAssignmentField in project drools by kiegroup.
the class FactAssignmentFieldPopulatorTest method addFactAssignmentFieldIntoFactAssignmentField.
private void addFactAssignmentFieldIntoFactAssignmentField(FactAssignmentField factAssignmentField, int times) {
if (times > 0) {
FactAssignmentField innerFactAssignmentField = createFactAssignmentField();
factAssignmentField.getFact().getFieldData().add(innerFactAssignmentField);
addFactAssignmentFieldIntoFactAssignmentField(innerFactAssignmentField, --times);
}
}
use of org.drools.workbench.models.testscenarios.shared.FactAssignmentField in project drools by kiegroup.
the class FactAssignmentFieldPopulatorTest method testSimpleFields.
@Test
public void testSimpleFields() throws Exception {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
TypeResolver typeResolver = new ClassTypeResolver(new HashSet<String>(), classLoader);
typeResolver.addImport("org.drools.workbench.models.testscenarios.backend.Cheese");
Mouse mouse = new Mouse();
FactAssignmentField factAssignmentField = new FactAssignmentField("cheese", "Cheese");
factAssignmentField.getFact().getFieldData().add(new FieldData("type", "Best cheddar EVER! (tm)"));
FactAssignmentFieldPopulator factAssignmentFieldPopulator = new FactAssignmentFieldPopulator(mouse, factAssignmentField, typeResolver);
factAssignmentFieldPopulator.populate(new HashMap<String, Object>());
assertEquals("Best cheddar EVER! (tm)", mouse.getCheese().getType());
}
use of org.drools.workbench.models.testscenarios.shared.FactAssignmentField in project drools by kiegroup.
the class FactAssignmentFieldPopulatorTest method testFactAssignmentField.
@Test
public void testFactAssignmentField() throws Exception {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
TypeResolver typeResolver = new ClassTypeResolver(new HashSet<String>(), classLoader);
typeResolver.addImport("org.drools.workbench.models.testscenarios.backend.Cheese");
Mouse mouse = new Mouse();
FactAssignmentField factAssignmentField = new FactAssignmentField("cheese", "Cheese");
FactAssignmentFieldPopulator factAssignmentFieldPopulator = new FactAssignmentFieldPopulator(mouse, factAssignmentField, typeResolver);
factAssignmentFieldPopulator.populate(new HashMap<String, Object>());
assertNotNull(mouse.getCheese());
}
use of org.drools.workbench.models.testscenarios.shared.FactAssignmentField in project drools by kiegroup.
the class FactAssignmentFieldPopulatorTest method testMatryoshkaDollSituation.
@Test
public void testMatryoshkaDollSituation() throws Exception {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
TypeResolver typeResolver = new ClassTypeResolver(new HashSet<String>(), classLoader);
typeResolver.addImport("org.drools.workbench.models.testscenarios.backend.MatryoshkaDoll");
MatryoshkaDoll matryoshkaDoll = new MatryoshkaDoll();
FactAssignmentField factAssignmentField = createFactAssignmentField();
addFactAssignmentFieldIntoFactAssignmentField(factAssignmentField, 5);
FactAssignmentFieldPopulator factAssignmentFieldPopulator = new FactAssignmentFieldPopulator(matryoshkaDoll, factAssignmentField, typeResolver);
factAssignmentFieldPopulator.populate(new HashMap<String, Object>());
assertNotNull(matryoshkaDoll.getMatryoshkaDoll());
assertNotNull(matryoshkaDoll.getMatryoshkaDoll().getMatryoshkaDoll());
assertNotNull(matryoshkaDoll.getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll());
assertNotNull(matryoshkaDoll.getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll());
assertNotNull(matryoshkaDoll.getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll());
assertNotNull(matryoshkaDoll.getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll());
assertNull(matryoshkaDoll.getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll().getMatryoshkaDoll());
}
use of org.drools.workbench.models.testscenarios.shared.FactAssignmentField in project drools by kiegroup.
the class FieldPopulatorFactoryTest method testFactAssignmentField.
@Test
public void testFactAssignmentField() throws Exception {
FactAssignmentField field = new FactAssignmentField();
field.setFact(new Fact());
Mockito.<Class>when(typeResolver.resolveType(Matchers.<String>any())).thenReturn(Cheese.class);
FieldPopulator fieldPopulator = fieldPopulatorFactory.getFieldPopulator(field);
assertNotNull(fieldPopulator);
}
Aggregations