use of org.drools.core.meta.org.test.AnotherKlass in project drools by kiegroup.
the class MetadataTest method testInitWithModifyArgs.
@Test
public void testInitWithModifyArgs() {
AnotherKlass aki = AnotherKlass_.newAnotherKlass("000").call();
SubKlass ski = SubKlass_.newSubKlass(URI.create("123"), With.with(aki)).prop("hello").subProp(42).another(aki).call();
Klass ki = Klass_.newKlass("1421").call();
assertEquals("hello", ski.getProp());
assertEquals(42, (int) ski.getSubProp());
assertEquals(aki, ski.getAnother());
}
use of org.drools.core.meta.org.test.AnotherKlass in project drools by kiegroup.
the class MetadataTest method testOneToOneProperty.
@Test
public void testOneToOneProperty() {
AnotherKlass aki0 = AnotherKlass_.newAnotherKlass("000").call();
Klass klass = Klass_.newKlass("001").call();
Klass_.modify(klass, With.with(aki0)).another(aki0).call();
assertSame(klass.getAnother(), aki0);
assertSame(klass, aki0.getTheKlass());
Klass klass1 = Klass_.newKlass("002").call();
AnotherKlass_.modify(aki0).theKlass(klass1).call();
assertSame(aki0, klass1.getAnother());
assertSame(klass1, aki0.getTheKlass());
Klass_.modify(klass).another(null).call();
assertNull(klass.getAnother());
assertNull(aki0.getTheKlass());
}
use of org.drools.core.meta.org.test.AnotherKlass 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());
}
use of org.drools.core.meta.org.test.AnotherKlass in project drools by kiegroup.
the class MetadataTest method testManyToManyProperty.
@Test
public void testManyToManyProperty() {
AnotherKlass aki1 = 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).manyOthers(aki1, Lit.ADD).call();
Klass_.modify(klass1).manyOthers(aki2, Lit.ADD).call();
AnotherKlass_.modify(aki2).manyMoreKlasses(klass2, Lit.ADD).call();
AnotherKlass_.modify(aki1).manyMoreKlasses(klass2, Lit.ADD).call();
assertTrue(klass1.getManyAnothers().contains(aki1));
assertTrue(klass1.getManyAnothers().contains(aki2));
assertTrue(klass2.getManyAnothers().contains(aki1));
assertTrue(klass2.getManyAnothers().contains(aki2));
assertTrue(aki1.getManyMoreKlasses().contains(klass1));
assertTrue(aki1.getManyMoreKlasses().contains(klass2));
assertTrue(aki2.getManyMoreKlasses().contains(klass1));
assertTrue(aki2.getManyMoreKlasses().contains(klass2));
AnotherKlass_.modify(aki2).manyMoreKlasses(klass2, Lit.REMOVE).call();
assertTrue(klass1.getManyAnothers().contains(aki1));
assertTrue(klass1.getManyAnothers().contains(aki2));
assertTrue(klass2.getManyAnothers().contains(aki1));
assertFalse(klass2.getManyAnothers().contains(aki2));
assertTrue(aki1.getManyMoreKlasses().contains(klass1));
assertTrue(aki1.getManyMoreKlasses().contains(klass2));
assertTrue(aki2.getManyMoreKlasses().contains(klass1));
assertFalse(aki2.getManyMoreKlasses().contains(klass2));
AnotherKlass_.modify(aki2).manyMoreKlasses(klass2, Lit.ADD).call();
assertTrue(klass1.getManyAnothers().contains(aki1));
assertTrue(klass1.getManyAnothers().contains(aki2));
assertTrue(klass2.getManyAnothers().contains(aki1));
assertTrue(klass2.getManyAnothers().contains(aki2));
assertTrue(aki1.getManyMoreKlasses().contains(klass1));
assertTrue(aki1.getManyMoreKlasses().contains(klass2));
assertTrue(aki2.getManyMoreKlasses().contains(klass1));
assertTrue(aki2.getManyMoreKlasses().contains(klass2));
AnotherKlass_.modify(aki2).manyMoreKlasses(klass2, Lit.SET).call();
assertTrue(klass1.getManyAnothers().contains(aki1));
assertFalse(klass1.getManyAnothers().contains(aki2));
assertTrue(klass2.getManyAnothers().contains(aki1));
assertTrue(klass2.getManyAnothers().contains(aki2));
assertTrue(aki1.getManyMoreKlasses().contains(klass1));
assertTrue(aki1.getManyMoreKlasses().contains(klass2));
assertFalse(aki2.getManyMoreKlasses().contains(klass1));
assertTrue(aki2.getManyMoreKlasses().contains(klass2));
}
use of org.drools.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));
}
Aggregations