@@ -3,6 +3,7 @@ package org.utbot.examples.lambda
33import org.junit.jupiter.api.Test
44import org.utbot.framework.plugin.api.CodegenLanguage
55import org.utbot.testcheckers.eq
6+ import org.utbot.testcheckers.withConcrete
67import org.utbot.tests.infrastructure.CodeGeneration
78import org.utbot.tests.infrastructure.DoNotCalculate
89import org.utbot.tests.infrastructure.UtValueTestCaseChecker
@@ -57,25 +58,40 @@ class CustomPredicateExampleTest : UtValueTestCaseChecker(
5758
5859 @Test
5960 fun testCapturedStaticFieldPredicateCheck () {
60- checkWithException (
61+ checkStatics (
6162 CustomPredicateExample ::capturedStaticFieldPredicateCheck,
6263 eq(3 ),
63- { predicate, x, r -> ! predicate.test(x) && r.getOrNull() == false },
64- { predicate, x, r -> predicate.test(x) && r.getOrNull() == true },
65- { predicate, _, r -> predicate == null && r.isException<NullPointerException >() },
64+ { predicate, x, statics, r ->
65+ val staticField = statics.values.singleOrNull()?.value as Int
66+ CustomPredicateExample .someStaticField = staticField
67+
68+ ! predicate.test(x) && r == false
69+ },
70+ { predicate, x, statics, r ->
71+ val staticField = statics.values.singleOrNull()?.value as Int
72+ CustomPredicateExample .someStaticField = staticField
73+
74+ predicate.test(x) && r == true
75+ },
76+ { predicate, _, _, _ ->
77+ predicate == null
78+ },
6679 coverage = DoNotCalculate
6780 )
6881 }
6982
7083 @Test
7184 fun testCapturedNonStaticFieldPredicateCheck () {
72- checkWithException(
73- CustomPredicateExample ::capturedNonStaticFieldPredicateCheck,
74- eq(3 ),
75- { predicate, x, r -> ! predicate.test(x) && r.getOrNull() == false },
76- { predicate, x, r -> predicate.test(x) && r.getOrNull() == true },
77- { predicate, _, r -> predicate == null && r.isException<NullPointerException >() },
78- coverage = DoNotCalculate
79- )
85+ // TODO fails without concrete https://github.com/UnitTestBot/UTBotJava/issues/1247
86+ withConcrete(useConcreteExecution = true ) {
87+ checkWithException(
88+ CustomPredicateExample ::capturedNonStaticFieldPredicateCheck,
89+ eq(3 ),
90+ { predicate, x, r -> ! predicate.test(x) && r.getOrNull() == false },
91+ { predicate, x, r -> predicate.test(x) && r.getOrNull() == true },
92+ { predicate, _, r -> predicate == null && r.isException<NullPointerException >() },
93+ coverage = DoNotCalculate
94+ )
95+ }
8096 }
8197}
0 commit comments