예제 #1
0
  @Test
  public void testTimerStartDateISO() throws Exception {

    byte[] content =
        IoUtils.readBytesFromInputStream(
            this.getClass().getResourceAsStream("/BPMN2-TimerStartDate.bpmn2"));
    String processContent = new String(content, "UTF-8");

    DateTime now = new DateTime(System.currentTimeMillis());
    now = now.plus(2000);

    processContent = processContent.replaceFirst("#\\{date\\}", now.toString());
    Resource resource = ResourceFactory.newReaderResource(new StringReader(processContent));
    resource.setSourcePath("/BPMN2-TimerStartDate.bpmn2");
    resource.setTargetPath("/BPMN2-TimerStartDate.bpmn2");
    KieBase kbase = createKnowledgeBaseFromResources(resource);

    ksession = createKnowledgeSession(kbase);
    final List<Long> list = new ArrayList<Long>();
    ksession.addEventListener(
        new DefaultProcessEventListener() {
          public void afterProcessStarted(ProcessStartedEvent event) {
            list.add(event.getProcessInstance().getId());
          }
        });
    assertEquals(0, list.size());
    Thread.sleep(3000);
    assertEquals(1, list.size());
  }
예제 #2
0
 public static KieBase getKieBaseAndBuildInstallModuleFromDrl(
     final String moduleGroupId,
     final KieBaseTestConfiguration kieBaseTestConfiguration,
     final String drl) {
   final Resource drlResource =
       KieServices.Factory.get().getResources().newReaderResource(new StringReader(drl));
   drlResource.setTargetPath(TestConstants.DRL_TEST_TARGET_PATH);
   return getKieBaseAndBuildInstallModule(moduleGroupId, kieBaseTestConfiguration, drlResource);
 }
예제 #3
0
 public static Resource getDecisionTableResourceFromClasspath(
     final String resourceName,
     final Class classLoaderFromClass,
     final DecisionTableInputType type) {
   final Resource dtable =
       KieServices.Factory.get()
           .getResources()
           .newClassPathResource(resourceName, classLoaderFromClass);
   final DecisionTableConfiguration resourceConfig = new DecisionTableConfigurationImpl();
   resourceConfig.setInputType(type);
   dtable.setConfiguration(resourceConfig);
   return dtable;
 }
예제 #4
0
 private List<Process> getProcessesGeneratedFromResource(Resource resource) {
   List<Process> processesFromResource = new ArrayList<Process>();
   for (Process process : ruleFlows.values()) {
     if (resource.equals(process.getResource())) {
       processesFromResource.add(process);
     }
   }
   return processesFromResource;
 }
예제 #5
0
 private List<Function> getFunctionsGeneratedFromResource(Resource resource) {
   List<Function> functionsFromResource = new ArrayList<Function>();
   for (Function function : functions.values()) {
     if (resource.equals(function.getResource())) {
       functionsFromResource.add(function);
     }
   }
   return functionsFromResource;
 }
예제 #6
0
 private List<TypeDeclaration> getTypesGeneratedFromResource(Resource resource) {
   List<TypeDeclaration> typesFromResource = new ArrayList<TypeDeclaration>();
   for (TypeDeclaration type : typeDeclarations.values()) {
     if (resource.equals(type.getResource())) {
       typesFromResource.add(type);
     }
   }
   return typesFromResource;
 }
예제 #7
0
 private List<RuleImpl> getRulesGeneratedFromResource(Resource resource) {
   List<RuleImpl> rulesFromResource = new ArrayList<RuleImpl>();
   for (RuleImpl rule : rules.values()) {
     if (resource.equals(rule.getResource())) {
       rulesFromResource.add(rule);
     }
   }
   return rulesFromResource;
 }
예제 #8
0
 private <T extends BaseDescr> void removeObjectsGeneratedFromResource(
     Resource resource, Collection<T> descrs) {
   Iterator<T> i = descrs.iterator();
   while (i.hasNext()) {
     if (resource.equals(i.next().getResource())) {
       i.remove();
     }
   }
 }
 public CompositeKnowledgeBuilder add(
     Resource resource, ResourceType type, ResourceChangeSet changes) {
   return add(resource, type, resource.getConfiguration(), changes);
 }
 public CompositeKnowledgeBuilder add(Resource resource, ResourceType type) {
   return add(resource, type, resource.getConfiguration());
 }