Search in sources :

Example 1 with SubKlassImpl

use of org.drools.core.meta.org.test.SubKlassImpl 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));
}
Also used : SubKlassImpl(org.drools.core.meta.org.test.SubKlassImpl) SubKlass_(org.drools.core.meta.org.test.SubKlass_) Test(org.junit.Test)

Example 2 with SubKlassImpl

use of org.drools.core.meta.org.test.SubKlassImpl 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());
}
Also used : AnotherKlass(org.drools.core.meta.org.test.AnotherKlass) Klass(org.drools.core.meta.org.test.Klass) SubKlass(org.drools.core.meta.org.test.SubKlass) AnotherKlass_(org.drools.core.meta.org.test.AnotherKlass_) Klass_(org.drools.core.meta.org.test.Klass_) SubKlass_(org.drools.core.meta.org.test.SubKlass_) SubKlass_(org.drools.core.meta.org.test.SubKlass_) SubKlassImpl(org.drools.core.meta.org.test.SubKlassImpl) AnotherKlass(org.drools.core.meta.org.test.AnotherKlass) SubKlass(org.drools.core.meta.org.test.SubKlass) SubKlassImpl(org.drools.core.meta.org.test.SubKlassImpl) AnotherKlassImpl(org.drools.core.meta.org.test.AnotherKlassImpl) KlassImpl(org.drools.core.meta.org.test.KlassImpl) AnotherKlassImpl(org.drools.core.meta.org.test.AnotherKlassImpl) AnotherKlass_(org.drools.core.meta.org.test.AnotherKlass_) Test(org.junit.Test)

Example 3 with SubKlassImpl

use of org.drools.core.meta.org.test.SubKlassImpl 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());
}
Also used : SubKlassImpl(org.drools.core.meta.org.test.SubKlassImpl) SubKlass_(org.drools.core.meta.org.test.SubKlass_) Test(org.junit.Test)

Example 4 with SubKlassImpl

use of org.drools.core.meta.org.test.SubKlassImpl in project drools by kiegroup.

the class MetadataTest method testKlassAndSubKlassWithImpl.

@Test
public void testKlassAndSubKlassWithImpl() {
    SubKlass ski = new SubKlassImpl();
    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().prop("bye").subProp(-99).call();
    assertEquals(-99, (int) sk.subProp.get(ski));
    assertEquals("bye", sk.prop.get(ski));
}
Also used : SubKlassImpl(org.drools.core.meta.org.test.SubKlassImpl) SubKlass_(org.drools.core.meta.org.test.SubKlass_) SubKlass(org.drools.core.meta.org.test.SubKlass) Test(org.junit.Test)

Example 5 with SubKlassImpl

use of org.drools.core.meta.org.test.SubKlassImpl in project drools by kiegroup.

the class MetadataTest method testMetadataModifyStyle.

@Test
public void testMetadataModifyStyle() {
    SubKlassImpl ski = new SubKlassImpl();
    SubKlass_.modify(ski).prop("hello").subProp(42).call();
    assertEquals("hello", ski.getProp());
    assertEquals(42, (int) ski.getSubProp());
}
Also used : SubKlassImpl(org.drools.core.meta.org.test.SubKlassImpl) Test(org.junit.Test)

Aggregations

SubKlassImpl (org.drools.core.meta.org.test.SubKlassImpl)5 Test (org.junit.Test)5 SubKlass_ (org.drools.core.meta.org.test.SubKlass_)4 SubKlass (org.drools.core.meta.org.test.SubKlass)2 AnotherKlass (org.drools.core.meta.org.test.AnotherKlass)1 AnotherKlassImpl (org.drools.core.meta.org.test.AnotherKlassImpl)1 AnotherKlass_ (org.drools.core.meta.org.test.AnotherKlass_)1 Klass (org.drools.core.meta.org.test.Klass)1 KlassImpl (org.drools.core.meta.org.test.KlassImpl)1 Klass_ (org.drools.core.meta.org.test.Klass_)1