下面列出了怎么用org.junit.jupiter.api.function.ThrowingSupplier的API类实例代码及写法,或者点击链接到github查看源代码。
@Test
public void testNoLoop() {
// DROOLS-644
String drl =
"import " + Person.class.getCanonicalName() + ";\n" +
"global java.util.List list;\n" +
"rule R no-loop when\n" +
" $p1 : Person( name == \"Mario\" ) do[t1]\n" +
" $p2 : Person( age > $p1.age )\n" +
"then\n" +
" list.add(\"t0\");\n" +
" modify($p2) { setAge(30); }\n" +
"then[t1]\n" +
" list.add(\"t1\");\n" +
" modify($p1) { setAge(35); }\n" +
"end\n";
// This test has uncovered a BLOCKER which is reported in the PropertyReactiveBlockersTest
KieSession ksession = new KieHelper(PropertySpecificOption.ALLOWED).addContent(drl, ResourceType.DRL)
.build()
.newKieSession();
List<String> list = new ArrayList<String>();
ksession.setGlobal("list", list);
Person mario = new Person("Mario", 40);
Person mark = new Person("Mark", 37);
ksession.insert(mario);
ksession.insert(mark);
assertTimeoutPreemptively(Duration.ofSeconds(10), (ThrowingSupplier<Integer>) ksession::fireAllRules);
assertEquals(35, mario.getAge());
assertEquals(30, mark.getAge());
assertEquals(2, list.size());
assertEquals("t1", list.get(0));
assertEquals("t0", list.get(1));
}
@Test
void defaultConstructorShouldBuildIndexCorrectly() {
assertDoesNotThrow((ThrowingSupplier<ProblemAdapterFactory>) ProblemAdapterFactory::new);
}
public MemoryReferenceTask(ThrowingSupplier<Result> task) {
this.task = task;
}