use of org.drools.core.meta.org.test.SubKlass in project drools by kiegroup.
the class MetadataTest method testNewInstance.
@Test
public void testNewInstance() {
Klass klass = Klass_.newKlass(URI.create("test")).call();
assertNotNull(klass);
assertTrue(klass instanceof KlassImpl);
SubKlass klass2 = SubKlass_.newSubKlass(URI.create("test2")).subProp(42).prop("hello").call();
assertEquals("hello", klass2.getProp());
assertEquals(42, (int) klass2.getSubProp());
}
use of org.drools.core.meta.org.test.SubKlass in project drools by kiegroup.
the class MetadataTest method testInitWithModifyArgs.
@Test
public void testInitWithModifyArgs() {
AnotherKlass aki = AnotherKlass_.newAnotherKlass("000").call();
SubKlass ski = SubKlass_.newSubKlass(URI.create("123"), With.with(aki)).prop("hello").subProp(42).another(aki).call();
Klass ki = Klass_.newKlass("1421").call();
assertEquals("hello", ski.getProp());
assertEquals(42, (int) ski.getSubProp());
assertEquals(aki, ski.getAnother());
}
use of org.drools.core.meta.org.test.SubKlass in project drools by kiegroup.
the class MetadataTest method testMetadataInternals.
@Test
public void testMetadataInternals() {
SubKlass_<SubKlass> sk = new SubKlass_(new SubKlassImpl());
Klass_<Klass> k = new Klass_(new KlassImpl());
AnotherKlass_<AnotherKlass> ak = new AnotherKlass_(new AnotherKlassImpl());
assertEquals(4, ak.getMetaClassInfo().getProperties().length);
assertEquals(4, sk.getMetaClassInfo().getProperties().length);
assertEquals(4, k.getMetaClassInfo().getProperties().length);
assertEquals("subProp", sk.getMetaClassInfo().getProperties()[2].getName());
}
use of org.drools.core.meta.org.test.SubKlass 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.meta.org.test.SubKlass in project drools by kiegroup.
the class MetadataTest method testMetaPropertiesWithManyKlasses.
@Test
public void testMetaPropertiesWithManyKlasses() {
SubKlass ski = new Foo();
ski.setSubProp(42);
ski.setProp("hello");
SubKlass_ sk = new SubKlass_(ski);
AnotherKlass aki = new AnotherKlassImpl();
aki.setNum(1);
AnotherKlass_ ak = new AnotherKlass_(aki);
sk.modify().subProp(-99).prop("bye").call();
ak.modify().num(-5).call();
assertEquals(-5, aki.getNum());
assertEquals(-99, (int) ski.getSubProp());
}
Aggregations