@Test
public void testMarshallingUnmarshalling() {
KieServices ks = KieServices.Factory.get();
KieModuleModel kproj = ks.newKieModuleModel();
KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("KBase1")
.setEqualsBehavior( EqualityBehaviorOption.EQUALITY )
.setEventProcessingMode( EventProcessingOption.STREAM )
.setDeclarativeAgenda( DeclarativeAgendaOption.ENABLED )
.addInclude("OtherKBase")
.addPackage("org.kie.pkg1")
.addPackage("org.kie.pkg2");
KieSessionModel ksession1 = kieBaseModel1.newKieSessionModel("KSession1")
.setType(KieSessionType.STATEFUL)
.setClockType(ClockTypeOption.get("realtime"))
.setBeliefSystem(BeliefSystemTypeOption.get("jtms"))
.setFileLogger("drools.log", 10, true)
.setDefault(true);
ksession1.newListenerModel("org.domain.FirstInterface", ListenerModel.Kind.AGENDA_EVENT_LISTENER);
ksession1.newListenerModel("org.domain.SecondInterface", ListenerModel.Kind.RULE_RUNTIME_EVENT_LISTENER)
.newQualifierModel("MyQualfier2");
ksession1.newListenerModel("org.domain.ThirdInterface", ListenerModel.Kind.PROCESS_EVENT_LISTENER)
.newQualifierModel("MyQualfier3")
.setValue("v1");
ksession1.newListenerModel("org.domain.FourthInterface", ListenerModel.Kind.AGENDA_EVENT_LISTENER)
.newQualifierModel("MyQualfier4")
.addArgument("name1", "xxxx")
.addArgument("name2", "yyyy");
ksession1.newWorkItemHandlerModel("name","org.domain.FifthInterface")
.newQualifierModel("MyQualfier5")
.addArgument("name1", "aaa")
.addArgument("name2", "bbb");
// KieBaseModel kieBaseModel2 = kproj.newKieBaseModel("KBase2")
// .setEqualsBehavior( EqualityBehaviorOption.EQUALITY )
// .setEventProcessingMode( EventProcessingOption.STREAM );
String xml = kproj.toXML();
// System.out.println( xml );
KieModuleModel kprojXml = fromXML(xml);
KieBaseModel kieBaseModelXML = kprojXml.getKieBaseModels().get("KBase1");
assertSame(kprojXml, ((KieBaseModelImpl)kieBaseModelXML).getKModule());
assertEquals(EqualityBehaviorOption.EQUALITY, kieBaseModelXML.getEqualsBehavior());
assertEquals(EventProcessingOption.STREAM, kieBaseModelXML.getEventProcessingMode());
assertEquals(DeclarativeAgendaOption.ENABLED, kieBaseModelXML.getDeclarativeAgenda());
assertFalse(kieBaseModelXML.isDefault());