use of org.drools.core.util.StandaloneTraitFactory in project drools by kiegroup.
the class LegacyTraitTest method testTraitWithNonAccessorMethodShadowing.
@Test
public void testTraitWithNonAccessorMethodShadowing() {
StandaloneTraitFactory factory = new StandaloneTraitFactory(ProjectClassLoader.createProjectClassLoader());
try {
SomeInterface r = (SomeInterface) factory.don(new SomeClass(), SomeInterface.class);
r.prepare();
assertEquals(42, r.getFoo());
assertEquals("I did that", r.doThis("that"));
} catch (LogicalTypeInconsistencyException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.drools.core.util.StandaloneTraitFactory in project drools by kiegroup.
the class StandaloneTest method init.
@Before
public void init() {
ProjectClassLoader loader = ProjectClassLoader.createProjectClassLoader();
factory = new StandaloneTraitFactory(loader);
}
use of org.drools.core.util.StandaloneTraitFactory in project drools by kiegroup.
the class MetadataTest method testDonWithAttributes.
@Test
public void testDonWithAttributes() {
Entity entity = new Entity("123");
entity._setDynamicProperties(new HashMap());
SubKlass klass = SubKlass_.donSubKlass(entity).setTraitFactory(new StandaloneTraitFactory(ProjectClassLoader.createProjectClassLoader())).prop("hello").subProp(32).call();
assertEquals("hello", klass.getProp());
assertEquals(32, (int) klass.getSubProp());
}
use of org.drools.core.util.StandaloneTraitFactory in project drools by kiegroup.
the class MetadataTest method testDon.
@Test
public void testDon() {
Entity entity = new Entity("123");
entity._setDynamicProperties(new HashMap());
entity._getDynamicProperties().put("prop", "hello");
Klass klass = Klass_.donKlass(entity).setTraitFactory(new StandaloneTraitFactory(ProjectClassLoader.createProjectClassLoader())).call();
assertEquals("hello", klass.getProp());
}
Aggregations