Search in sources :

Example 6 with AnotherKlass

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

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

the class MetadataTest method testManyToOneProperty.

@Test
public void testManyToOneProperty() {
    AnotherKlass aki = AnotherKlass_.newAnotherKlass("000").call();
    AnotherKlass aki2 = AnotherKlass_.newAnotherKlass("999").call();
    Klass klass1 = Klass_.newKlass("001").call();
    Klass klass2 = Klass_.newKlass("002").call();
    Klass_.modify(klass1).oneAnother(aki).call();
    Klass_.modify(klass2).oneAnother(aki).call();
    assertSame(aki, klass1.getOneAnother());
    assertSame(aki, klass2.getOneAnother());
    assertEquals(Arrays.asList(klass1, klass2), aki.getManyKlasses());
    Klass_.modify(klass1).oneAnother(aki2).call();
    assertSame(aki2, klass1.getOneAnother());
    assertEquals(Arrays.asList(klass1), aki2.getManyKlasses());
    assertEquals(Arrays.asList(klass2), aki.getManyKlasses());
}
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) Test(org.junit.Test)

Example 8 with AnotherKlass

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

the class MetadataTest method testCollectionOrientedProperties.

@Test
public void testCollectionOrientedProperties() {
    AnotherKlass aki0 = AnotherKlass_.newAnotherKlass("000").call();
    AnotherKlass aki1 = AnotherKlass_.newAnotherKlass("001").call();
    AnotherKlass aki2 = AnotherKlass_.newAnotherKlass("002").call();
    AnotherKlass aki3 = AnotherKlass_.newAnotherKlass("003").call();
    AnotherKlass aki4 = AnotherKlass_.newAnotherKlass("004").call();
    ArrayList<AnotherKlass> initial = new ArrayList(Arrays.asList(aki0, aki1));
    SubKlass ski = SubKlass_.newSubKlass(URI.create("123")).links(initial, Lit.SET).links(aki1, Lit.REMOVE).links(aki2, Lit.ADD).links(Arrays.asList(aki3, aki4), Lit.REMOVE).call();
    assertEquals(Arrays.asList(aki0, aki2), ski.getLinks());
}
Also used : AnotherKlass(org.drools.core.meta.org.test.AnotherKlass) ArrayList(java.util.ArrayList) SubKlass(org.drools.core.meta.org.test.SubKlass) Test(org.junit.Test)

Aggregations

AnotherKlass (org.drools.core.meta.org.test.AnotherKlass)8 SubKlass (org.drools.core.meta.org.test.SubKlass)8 Test (org.junit.Test)8 Klass (org.drools.core.meta.org.test.Klass)6 ArrayList (java.util.ArrayList)2 AnotherKlassImpl (org.drools.core.meta.org.test.AnotherKlassImpl)2 AnotherKlass_ (org.drools.core.meta.org.test.AnotherKlass_)2 SubKlass_ (org.drools.core.meta.org.test.SubKlass_)2 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