use of org.drools.core.meta.org.test.SubKlass_ in project drools by kiegroup.
the class MetadataTest method testKlassAndSubKlassWithHolderImpl.
@Test
public void testKlassAndSubKlassWithHolderImpl() {
SubKlassImpl ski = new SubKlassImpl();
ski.setSubProp(42);
ski.setProp("hello");
SubKlass_ sk = ski.get_();
assertEquals(42, (int) sk.subProp.get(ski));
assertEquals("hello", sk.prop.get(ski));
sk.modify().prop("bye").subProp(-99).call();
assertEquals(-99, (int) sk.subProp.get(ski));
assertEquals("bye", sk.prop.get(ski));
}
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 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());
}
use of org.drools.core.meta.org.test.SubKlass_ in project drools by kiegroup.
the class MetadataTest method testModificationMask.
@Test
public void testModificationMask() {
SubKlassImpl ski = new SubKlassImpl();
SubKlass_.SubKlass_Modify task = SubKlass_.modify(ski).prop("hello").subProp(42);
task.call();
assertEquals("144", task.getModificationMask().toString());
SubKlass_.SubKlass_Modify task2 = SubKlass_.modify(ski).prop("hello");
task2.call();
assertEquals("16", task2.getModificationMask().toString());
SubKlass_.SubKlass_Modify task3 = SubKlass_.modify(ski).subProp(42);
task3.call();
assertEquals("128", task3.getModificationMask().toString());
}
use of org.drools.core.meta.org.test.SubKlass_ in project drools by kiegroup.
the class MetadataTest method testKlassAndSubKlassWithInterfaces.
@Test
public void testKlassAndSubKlassWithInterfaces() {
SubKlass ski = new Foo();
ski.setSubProp(42);
ski.setProp("hello");
SubKlass_ sk = new SubKlass_(ski);
assertEquals(42, (int) sk.subProp.get(ski));
assertEquals("hello", sk.prop.get(ski));
sk.modify().subProp(-99).prop("bye").call();
assertEquals(-99, (int) sk.subProp.get(ski));
assertEquals("bye", sk.prop.get(ski));
System.out.println(((Foo) ski).map);
Map tgt = new HashMap();
tgt.put("prop", "bye");
tgt.put("subProp", -99);
assertEquals(tgt, ((Foo) ski).map);
}
Aggregations