private InternalKieModule createKieJar(KieServices ks, KieFactory kf, GAV gav, String... rules)
      throws IOException {
    KieFileSystem kfs = kf.newKieFileSystem();
    for (String rule : rules) {
      String file = "org/test/" + rule + ".drl";
      kfs.write("src/main/resources/KBase1/" + file, createDRL(rule));
    }

    KieModuleModel kproj = kf.newKieModuleModel();

    KieBaseModel kieBaseModel1 =
        kproj
            .newKieBaseModel("KBase1")
            .setEqualsBehavior(AssertBehaviorOption.EQUALITY)
            .setEventProcessingMode(EventProcessingOption.STREAM);

    KieSessionModel ksession1 =
        kieBaseModel1
            .newKieSessionModel("KSession1")
            .setType(KieSessionType.STATEFUL)
            .setClockType(ClockTypeOption.get("realtime"));

    kfs.writeKModuleXML(kproj.toXML());
    kfs.writePomXML(getPom(gav));

    KieBuilder kieBuilder = ks.newKieBuilder(kfs);
    assertTrue(kieBuilder.build().getInsertedMessages().isEmpty());
    return (InternalKieModule) kieBuilder.getKieModule();
  }
  private InternalKieModule createKieJarWithClass(
      KieServices ks, KieFactory kf, GAV gav, int value, int factor) throws IOException {
    KieFileSystem kieFileSystem = kf.newKieFileSystem();

    KieModuleModel kproj = kf.newKieModuleModel();

    KieBaseModel kieBaseModel1 =
        kproj
            .newKieBaseModel("KBase1")
            .setEqualsBehavior(AssertBehaviorOption.EQUALITY)
            .setEventProcessingMode(EventProcessingOption.STREAM);

    KieSessionModel ksession1 =
        kieBaseModel1
            .newKieSessionModel("KSession1")
            .setType(KieSessionType.STATEFUL)
            .setClockType(ClockTypeOption.get("realtime"));

    kieFileSystem
        .writeKModuleXML(kproj.toXML())
        .writePomXML(getPom(gav))
        .write(
            "src/main/resources/" + kieBaseModel1.getName() + "/rule1.drl",
            createDRLForJavaSource(value))
        .write("src/main/java/org/kie/test/Bean.java", createJavaSource(factor));

    KieBuilder kieBuilder = ks.newKieBuilder(kieFileSystem);
    assertTrue(kieBuilder.build().getInsertedMessages().isEmpty());
    return (InternalKieModule) kieBuilder.getKieModule();
  }
Ejemplo n.º 3
0
  private KieModuleModel createKieProjectWithPackages(KieServices ks, String pkg) {
    KieModuleModel kproj = ks.newKieModuleModel();

    KieBaseModel kieBaseModel1 =
        kproj
            .newKieBaseModel("KBase1")
            .setEqualsBehavior(EqualityBehaviorOption.EQUALITY)
            .setEventProcessingMode(EventProcessingOption.STREAM)
            .addPackage(pkg);

    KieSessionModel ksession1 =
        kieBaseModel1
            .newKieSessionModel("KSession1")
            .setType(KieSessionType.STATEFUL)
            .setClockType(ClockTypeOption.get("realtime"));

    return kproj;
  }