1+ package  examples.collections 
2+ 
3+ import  examples.SummaryTestCaseGeneratorTest 
4+ import  org.junit.jupiter.api.Test 
5+ import  org.utbot.examples.DoNotCalculate 
6+ import  org.utbot.examples.collections.ListWrapperReturnsVoidExample 
7+ import  org.utbot.framework.plugin.api.MockStrategyApi 
8+ 
9+ /* *
10+  * Tests verify that the previously discovered bug is not reproducible anymore. 
11+  * 
12+  * To get more details, see [issue-437](https://github.com/UnitTestBot/UTBotJava/issues/437) 
13+  */  
14+ class  SummaryListWrapperReturnsVoidTest  : SummaryTestCaseGeneratorTest (
15+     ListWrapperReturnsVoidExample : :class,
16+ ) {
17+     @Test
18+     fun  testRunForEach () {
19+         val  summary1 =  " Test throws NullPointerException in: list.forEach(o -> {\n "   + 
20+                 "     if (o == null)\n "   + 
21+                 "         i[0]++;\n "   + 
22+                 " });" 
23+         val  summary2 =  " Test returns from: return i[0];" 
24+         val  summary3 =  " Test returns from: return i[0];" 
25+         val  summary4 =  " Test returns from: return i[0];" 
26+ 
27+         val  methodName1 =  " testRunForEach_ThrowNullPointerException" 
28+         val  methodName2 =  " testRunForEach_Return0OfI" 
29+         val  methodName3 =  " testRunForEach_Return0OfI_1" 
30+         val  methodName4 =  " testRunForEach_Return0OfI_2" 
31+ 
32+         val  displayName1 =  " list.forEach(o -> { if (o == null) i[0]++ }) : True -> ThrowNullPointerException" 
33+         val  displayName2 =  " -> return i[0]" 
34+         val  displayName3 =  " -> return i[0]" 
35+         val  displayName4 =  " -> return i[0]" 
36+ 
37+         val  summaryKeys =  listOf (
38+             summary1,
39+             summary2,
40+             summary3,
41+             summary4
42+         )
43+ 
44+         val  displayNames =  listOf (
45+             displayName1,
46+             displayName2,
47+             displayName3,
48+             displayName4
49+         )
50+ 
51+         val  methodNames =  listOf (
52+             methodName1,
53+             methodName2,
54+             methodName3,
55+             methodName4
56+         )
57+ 
58+         val  method =  ListWrapperReturnsVoidExample ::runForEach
59+         val  mockStrategy =  MockStrategyApi .NO_MOCKS 
60+         val  coverage =  DoNotCalculate 
61+ 
62+         check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
63+     }
64+ 
65+     @Test
66+     fun  testSumPositiveForEach () {
67+         val  summary1 =  " Test throws NullPointerException in: list.forEach(i -> {\n "   + 
68+                 "     if (i > 0) {\n "   + 
69+                 "         sum[0] += i;\n "   + 
70+                 "     }\n "   + 
71+                 " });" 
72+         val  summary2 =  " Test invokes: List::forEach once\n "   + 
73+                 " throws NullPointerException in: list.forEach(i -> {\n "   + 
74+                 "     if (i > 0) {\n "   + 
75+                 "         sum[0] += i;\n "   + 
76+                 "     }\n "   + 
77+                 " });" 
78+         val  summary3 =  " Test executes conditions:\n "   + 
79+                 "     (sum[0] == 0): True\n "   + 
80+                 " returns from: return 0;" 
81+         val  summary4 =  " Test executes conditions:\n "   + 
82+                 "     (sum[0] == 0): True\n "   + 
83+                 " returns from: return 0;" 
84+         val  summary5 =  " Test executes conditions:\n "   + 
85+                 "     (sum[0] == 0): False\n "   + 
86+                 " returns from: return sum[0];" 
87+ 
88+         val  methodName1 =  " testSumPositiveForEach_ThrowNullPointerException" 
89+         val  methodName2 =  " testSumPositiveForEach_ListForEach" 
90+         val  methodName3 =  " testSumPositiveForEach_0OfSumEqualsZero" 
91+         val  methodName4 =  " testSumPositiveForEach_0OfSumEqualsZero_1" 
92+         val  methodName5 =  " testSumPositiveForEach_0OfSumNotEqualsZero" 
93+ 
94+         val  displayName1 =  " list.forEach(i -> { if (i > 0) { sum[0] += i } }) : True -> ThrowNullPointerException" 
95+         val  displayName2 =  " list.forEach(i -> { if (i > 0) { sum[0] += i } }) : True -> ThrowNullPointerException" 
96+         val  displayName3 =  " sum[0] == 0 : True -> return 0" 
97+         val  displayName4 =  " sum[0] == 0 : True -> return 0" 
98+         val  displayName5 =  " sum[0] == 0 : False -> return sum[0]" 
99+ 
100+         val  summaryKeys =  listOf (
101+             summary1,
102+             summary2,
103+             summary3,
104+             summary4,
105+             summary5
106+         )
107+ 
108+         val  displayNames =  listOf (
109+             displayName1,
110+             displayName2,
111+             displayName3,
112+             displayName4,
113+             displayName5
114+         )
115+ 
116+         val  methodNames =  listOf (
117+             methodName1,
118+             methodName2,
119+             methodName3,
120+             methodName4,
121+             methodName5
122+         )
123+ 
124+         val  method =  ListWrapperReturnsVoidExample ::sumPositiveForEach
125+         val  mockStrategy =  MockStrategyApi .NO_MOCKS 
126+         val  coverage =  DoNotCalculate 
127+ 
128+         check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
129+     }
130+ }
0 commit comments