1+ package generatedtest ;
2+
3+ import java .util .Optional ;
4+ import java .util .stream .Stream ;
5+
6+ // Test case generated by GenerateFlowTestCase.ql
7+ public class Test {
8+
9+ Object getElement (Optional <Object > container ) { return container .get (); }
10+ Object getStreamElement (Stream <Object > container ) { return null ; /* Modelled in .ql file */ }
11+ Optional <Object > newWithElement (Object element ) { return Optional .of (element ); }
12+ Object source () { return null ; }
13+ void sink (Object o ) { }
14+
15+ public void test () {
16+
17+ {
18+ // "java.util;Optional;false;filter;;;Element of Argument[-1];Element of ReturnValue;value"
19+ Optional <Object > out = null ;
20+ Optional <Object > in = newWithElement (source ());
21+ out = in .filter (null );
22+ sink (getElement (out )); // $hasValueFlow
23+ }
24+ {
25+ // "java.util;Optional;false;get;;;Element of Argument[-1];ReturnValue;value"
26+ Object out = null ;
27+ Optional <Object > in = newWithElement (source ());
28+ out = in .get ();
29+ sink (out ); // $hasValueFlow
30+ }
31+ {
32+ // "java.util;Optional;false;of;;;Argument[0];Element of ReturnValue;value"
33+ Optional <Object > out = null ;
34+ Object in = (Object )source ();
35+ out = Optional .of (in );
36+ sink (getElement (out )); // $hasValueFlow
37+ }
38+ {
39+ // "java.util;Optional;false;ofNullable;;;Argument[0];Element of ReturnValue;value"
40+ Optional <Object > out = null ;
41+ Object in = (Object )source ();
42+ out = Optional .ofNullable (in );
43+ sink (getElement (out )); // $hasValueFlow
44+ }
45+ {
46+ // "java.util;Optional;false;or;;;Element of Argument[-1];Element of ReturnValue;value"
47+ Optional <Object > out = null ;
48+ Optional <Object > in = newWithElement (source ());
49+ out = in .or (null );
50+ sink (getElement (out )); // $hasValueFlow
51+ }
52+ {
53+ // "java.util;Optional;false;orElse;;;Argument[0];ReturnValue;value"
54+ Object out = null ;
55+ Object in = (Object )source ();
56+ Optional <Object > instance = null ;
57+ out = instance .orElse (in );
58+ sink (out ); // $hasValueFlow
59+ }
60+ {
61+ // "java.util;Optional;false;orElse;;;Element of Argument[-1];ReturnValue;value"
62+ Object out = null ;
63+ Optional <Object > in = newWithElement (source ());
64+ out = in .orElse (null );
65+ sink (out ); // $hasValueFlow
66+ }
67+ {
68+ // "java.util;Optional;false;orElseGet;;;Element of Argument[-1];ReturnValue;value"
69+ Object out = null ;
70+ Optional <Object > in = newWithElement (source ());
71+ out = in .orElseGet (null );
72+ sink (out ); // $hasValueFlow
73+ }
74+ {
75+ // "java.util;Optional;false;orElseThrow;;;Element of Argument[-1];ReturnValue;value"
76+ Object out = null ;
77+ Optional <Object > in = newWithElement (source ());
78+ out = in .orElseThrow (null );
79+ sink (out ); // $hasValueFlow
80+ }
81+ {
82+ // "java.util;Optional;false;orElseThrow;;;Element of Argument[-1];ReturnValue;value"
83+ Object out = null ;
84+ Optional <Object > in = newWithElement (source ());
85+ out = in .orElseThrow ();
86+ sink (out ); // $hasValueFlow
87+ }
88+ {
89+ // "java.util;Optional;false;stream;;;Element of Argument[-1];Element of ReturnValue;value"
90+ Stream <Object > out = null ;
91+ Optional <Object > in = newWithElement (source ());
92+ out = in .stream ();
93+ sink (getStreamElement (out )); // $hasValueFlow
94+ }
95+
96+ }
97+
98+ }
0 commit comments