1+ package dev .openfeature .sdk ;
2+
3+ import com .google .common .collect .Lists ;
4+ import org .junit .jupiter .api .Test ;
5+
6+ import java .time .Instant ;
7+
8+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
9+ import static org .junit .jupiter .api .Assertions .assertEquals ;
10+
11+ class MutableTrackingEventDetailsTest {
12+
13+
14+ @ Test
15+ void hasDefaultValue () {
16+ MutableTrackingEventDetails track = new MutableTrackingEventDetails ();
17+ assertEquals (0.0f , track .getValue ());
18+ }
19+
20+ @ Test
21+ void shouldUseCorrectValue () {
22+ MutableTrackingEventDetails track = new MutableTrackingEventDetails (3 );
23+ assertEquals (3 , track .getValue ());
24+ }
25+
26+ @ Test
27+ void shouldStoreAttributes () {
28+ MutableTrackingEventDetails track = new MutableTrackingEventDetails ();
29+ track .add ("key0" , true );
30+ track .add ("key1" , 1 );
31+ track .add ("key2" , "2" );
32+ track .add ("key3" , 1d );
33+ track .add ("key4" , 4 );
34+ track .add ("key5" , Instant .parse ("2023-12-03T10:15:30Z" ));
35+ track .add ("key6" , new MutableContext ());
36+ track .add ("key7" , new Value (7 ));
37+ track .add ("key8" , Lists .newArrayList (new Value (8 ), new Value (9 )));
38+
39+ assertEquals (new Value (true ), track .getValue ("key0" ));
40+ assertEquals (new Value (1 ), track .getValue ("key1" ));
41+ assertEquals (new Value ("2" ), track .getValue ("key2" ));
42+ assertEquals (new Value (1d ), track .getValue ("key3" ));
43+ assertEquals (new Value (4 ), track .getValue ("key4" ));
44+ assertEquals (new Value (Instant .parse ("2023-12-03T10:15:30Z" )), track .getValue ("key5" ));
45+ assertEquals (new Value (new MutableContext ()), track .getValue ("key6" ));
46+ assertEquals (new Value (7 ), track .getValue ("key7" ));
47+ assertArrayEquals (new Object []{new Value (8 ), new Value (9 )}, track .getValue ("key8" ).asList ().toArray ());
48+ }
49+ }
0 commit comments