Search in sources :

Example 1 with AnotherKlassImpl

use of org.drools.core.meta.org.test.AnotherKlassImpl 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 2 with AnotherKlassImpl

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

Example 3 with AnotherKlassImpl

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

the class MetadataTest method testURIs.

@Test
public void testURIs() {
    AnotherKlassImpl aki = new AnotherKlassImpl();
    assertEquals(URI.create("http://www.test.org#AnotherKlass"), aki.get_().getMetaClassInfo().getUri());
    assertEquals(URI.create("http://www.test.org#AnotherKlass?num"), aki.get_().num.getUri());
    URI uri = AnotherKlass_.getIdentifier(aki);
    assertEquals(URI.create("http://www.test.org#AnotherKlass/AnotherKlassImpl/" + System.identityHashCode(aki)), uri);
    assertEquals(URI.create(uri.toString() + "/modify?num"), AnotherKlass_.modify(aki).num(33).getUri());
    assertTrue(uri.toString().startsWith(aki.get_().getMetaClassInfo().getUri().toString()));
    assertEquals(URI.create("http://www.test.org#SubKlass/123?create"), SubKlass_.newSubKlass(URI.create("http://www.test.org#SubKlass/123")).getUri());
    assertEquals(URI.create("123?don=org.drools.core.meta.org.test.AnotherKlass"), aki.get_().donAnotherKlass(new Foo()).getUri());
}
Also used : AnotherKlassImpl(org.drools.core.meta.org.test.AnotherKlassImpl) URI(java.net.URI) Test(org.junit.Test)

Aggregations

AnotherKlassImpl (org.drools.core.meta.org.test.AnotherKlassImpl)3 Test (org.junit.Test)3 AnotherKlass (org.drools.core.meta.org.test.AnotherKlass)2 AnotherKlass_ (org.drools.core.meta.org.test.AnotherKlass_)2 SubKlass (org.drools.core.meta.org.test.SubKlass)2 SubKlass_ (org.drools.core.meta.org.test.SubKlass_)2 URI (java.net.URI)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 SubKlassImpl (org.drools.core.meta.org.test.SubKlassImpl)1