@Override @CheckReturnValue public SELF withFailMessage(String newErrorMessage, Object... args) { return super.withFailMessage(newErrorMessage, args); }
@Override @CheckReturnValue public SELF withFailMessage(String newErrorMessage, Object... args) { return super.withFailMessage(newErrorMessage, args); }
@Test @Ignore("Process does not complete.") public void testAdHocSubProcessAutoComplete() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-AdHocSubProcessAutoComplete.bpmn2"); KieSession ksession = createKnowledgeSession(kbase); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); ProcessInstance processInstance = ksession.startProcess("AdHocSubProcess"); assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE); WorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNull(); ksession = restoreSession(ksession); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); ksession.fireAllRules(); workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull().withFailMessage("WorkItem should not be null."); ksession = restoreSession(ksession); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null); assertProcessInstanceCompleted(processInstance.getId(), ksession); }
@Override public final void check() throws Exception { final TypeDescription typeDescription = new TypeDescription.ForLoadedType(type); final DynamicType.Builder<?> subclass = new ByteBuddy().redefine(type); final DynamicType.Unloaded<?> make = builderTransition .transitionResult(subclass, typeDescription) .make(); final Class<?> clazz = make.load(new AnonymousClassLoader(), ClassLoadingStrategy.Default.CHILD_FIRST).getLoaded(); assertThat(clazz.getAnnotation(annotation)) .withFailMessage("Expected annotation %s is missing on class %s", annotation.getName(), clazz.getName()) .isNotNull(); }
@Test public void startRouterAndAwait() throws InterruptedException { ExecutorService ex = Executors.newSingleThreadExecutor(); AtomicReference<DisposableServer> ref = new AtomicReference<>(); Future<?> f = ex.submit(() -> HttpServer.create() .port(0) .route(routes -> routes.get("/hello", (req, resp) -> resp.sendString(Mono.just("hello!")))) .wiretap(true) .bindUntilJavaShutdown(Duration.ofSeconds(2), ref::set) ); //if the server cannot be started, a ExecutionException will be thrown instead assertThatExceptionOfType(TimeoutException.class) .isThrownBy(() -> f.get(1, TimeUnit.SECONDS)); //the router is not done and is still blocking the thread assertThat(f.isDone()).isFalse(); assertThat(ref.get()).isNotNull().withFailMessage("Server is not initialized after 1s"); //shutdown the router to unblock the thread ref.get().disposeNow(); Thread.sleep(100); assertThat(f.isDone()).isTrue(); }
private void assertSyntacticSuccessor(CfgBlock actualBlock) { String blockTestId = expectedCfg.testId(actualBlock); String expectedSyntSucc = expectedCfg.expectedSyntSucc(actualBlock); if (expectedSyntSucc != null) { if (expectedSyntSucc.equals(ExpectedCfgStructure.EMPTY)) { assertThat(actualBlock.syntacticSuccessor().elements()) .withFailMessage("syntactic successor should be _empty", blockTestId) .isEmpty(); } else { assertThat(actualBlock.syntacticSuccessor()) .withFailMessage(buildDebugMessage("syntactic successor", blockTestId)) .isEqualTo(expectedCfg.cfgBlock(expectedSyntSucc)); } } else { assertThat(actualBlock.syntacticSuccessor()).withFailMessage(buildDebugMessage("syntactic successor", blockTestId)).isNull(); } }
@Test @Ignore("Process does not complete.") public void testAdHocSubProcessAutoComplete() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-AdHocSubProcessAutoComplete.bpmn2"); KieSession ksession = createKnowledgeSession(kbase); TestWorkItemHandler workItemHandler = new TestWorkItemHandler(); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); ProcessInstance processInstance = ksession.startProcess("AdHocSubProcess"); assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE); WorkItem workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNull(); ksession = restoreSession(ksession); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); ksession.fireAllRules(); workItem = workItemHandler.getWorkItem(); assertThat(workItem).isNotNull().withFailMessage("WorkItem should not be null."); ksession = restoreSession(ksession); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler); ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null); assertProcessInstanceCompleted(processInstance.getId(), ksession); }