11package dev .openfeature .javasdk ;
22
33import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertThrows ;
45import static org .junit .jupiter .api .Assertions .assertTrue ;
6+ import static org .junit .jupiter .api .Assertions .fail ;
57
68import java .time .Instant ;
79import java .util .ArrayList ;
@@ -16,9 +18,44 @@ public class ValueTest {
1618 }
1719
1820 @ Test public void objectArgShouldContainObject () {
19- Object innerValue = new Object ();
20- Value value = new Value (innerValue );
21- assertEquals (innerValue , value .asObject ());
21+ try {
22+ // int is a special case, see intObjectArgShouldConvertToInt()
23+ List <Object > list = new ArrayList <>();
24+ list .add (true );
25+ list .add ("val" );
26+ list .add (.5 );
27+ list .add (new Structure ());
28+ list .add (new ArrayList <Value >());
29+ list .add (Instant .now ());
30+
31+ int i = 0 ;
32+ for (Object l : list ) {
33+ Value value = new Value (l );
34+ assertEquals (list .get (i ), value .asObject ());
35+ i ++;
36+ }
37+ } catch (Exception e ) {
38+ fail ("No exception expected." );
39+ }
40+ }
41+
42+ @ Test public void intObjectArgShouldConvertToInt () {
43+ try {
44+ Object innerValue = 1 ;
45+ Value value = new Value (innerValue );
46+ assertEquals (innerValue , value .asInteger ());
47+ } catch (Exception e ) {
48+ fail ("No exception expected." );
49+ }
50+ }
51+
52+ @ Test public void invalidObjectArgShouldThrow () {
53+
54+ class Something {}
55+
56+ assertThrows (InstantiationException .class , () -> {
57+ new Value (new Something ());
58+ });
2259 }
2360
2461 @ Test public void boolArgShouldContainBool () {
0 commit comments