use of org.drools.traits.core.meta.org.test.AnotherKlass in project drools by kiegroup.
the class MetadataTest method testOneToManyProperty.
@Test
public void testOneToManyProperty() {
AnotherKlass aki = AnotherKlass_.newAnotherKlass("000").call();
AnotherKlass aki2 = AnotherKlass_.newAnotherKlass("999").call();
Klass klass1 = Klass_.newKlass("001").call();
Klass klass2 = Klass_.newKlass("002").call();
AnotherKlass_.modify(aki, With.with(klass1, klass2)).manyKlasses(new ArrayList(Arrays.asList(klass1, klass2)), Lit.SET).call();
assertSame(aki, klass1.getOneAnother());
assertSame(aki, klass2.getOneAnother());
AnotherKlass_.modify(aki2).manyKlasses(klass1, Lit.ADD).call();
assertSame(aki2, klass1.getOneAnother());
assertSame(aki, klass2.getOneAnother());
assertFalse(aki.getManyKlasses().contains(klass1));
assertTrue(aki2.getManyKlasses().contains(klass1));
assertTrue(aki.getManyKlasses().contains(klass2));
AnotherKlass_.modify(aki2).manyKlasses(klass1, Lit.REMOVE).call();
assertNull(klass1.getOneAnother());
assertFalse(aki2.getManyKlasses().contains(klass1));
}
use of org.drools.traits.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.traits.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());
}
Aggregations