Search in sources :

Example 6 with SubKlass

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

the class MetadataTest method testKlassAndSubKlassWithInterfaces.

@Test
public void testKlassAndSubKlassWithInterfaces() {
    SubKlass ski = new Foo();
    ski.setSubProp(42);
    ski.setProp("hello");
    SubKlass_ sk = new SubKlass_(ski);
    assertEquals(42, (int) sk.subProp.get(ski));
    assertEquals("hello", sk.prop.get(ski));
    sk.modify().subProp(-99).prop("bye").call();
    assertEquals(-99, (int) sk.subProp.get(ski));
    assertEquals("bye", sk.prop.get(ski));
    System.out.println(((Foo) ski).map);
    Map tgt = new HashMap();
    tgt.put("prop", "bye");
    tgt.put("subProp", -99);
    assertEquals(tgt, ((Foo) ski).map);
}
Also used : HashMap(java.util.HashMap) SubKlass_(org.drools.core.meta.org.test.SubKlass_) SubKlass(org.drools.core.meta.org.test.SubKlass) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 7 with SubKlass

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

the class MetadataTest method testKlassAndSubKlassWithImpl.

@Test
public void testKlassAndSubKlassWithImpl() {
    SubKlass ski = new SubKlassImpl();
    ski.setSubProp(42);
    ski.setProp("hello");
    SubKlass_ sk = new SubKlass_(ski);
    assertEquals(42, (int) sk.subProp.get(ski));
    assertEquals("hello", sk.prop.get(ski));
    sk.modify().prop("bye").subProp(-99).call();
    assertEquals(-99, (int) sk.subProp.get(ski));
    assertEquals("bye", sk.prop.get(ski));
}
Also used : SubKlassImpl(org.drools.core.meta.org.test.SubKlassImpl) SubKlass_(org.drools.core.meta.org.test.SubKlass_) SubKlass(org.drools.core.meta.org.test.SubKlass) Test(org.junit.Test)

Example 8 with SubKlass

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

SubKlass (org.drools.core.meta.org.test.SubKlass)8 Test (org.junit.Test)8 AnotherKlass (org.drools.core.meta.org.test.AnotherKlass)5 SubKlass_ (org.drools.core.meta.org.test.SubKlass_)4 AnotherKlassImpl (org.drools.core.meta.org.test.AnotherKlassImpl)3 Klass (org.drools.core.meta.org.test.Klass)3 SubKlassImpl (org.drools.core.meta.org.test.SubKlassImpl)3 HashMap (java.util.HashMap)2 AnotherKlass_ (org.drools.core.meta.org.test.AnotherKlass_)2 KlassImpl (org.drools.core.meta.org.test.KlassImpl)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Entity (org.drools.core.factmodel.traits.Entity)1 Klass_ (org.drools.core.meta.org.test.Klass_)1 StandaloneTraitFactory (org.drools.core.util.StandaloneTraitFactory)1