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());
}
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());
}
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());
}
Aggregations