File tree Expand file tree Collapse file tree 7 files changed +173
-0
lines changed
src/test/java/dev/openfeature/sdk Expand file tree Collapse file tree 7 files changed +173
-0
lines changed Original file line number Diff line number Diff line change 1+ package dev .openfeature .sdk ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import dev .openfeature .sdk .fixtures .HookFixtures ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ class BooleanHookTest implements HookFixtures {
10+
11+ private Hook <Boolean > hook ;
12+
13+ @ BeforeEach
14+ void setupTest () {
15+ hook = mockBooleanHook ();
16+ }
17+
18+ @ Test
19+ void verifyFlagValueTypeIsSupportedByHook () {
20+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .BOOLEAN );
21+
22+ assertThat (hookSupported ).isTrue ();
23+ }
24+
25+ @ Test
26+ void verifyFlagValueTypeIsNotSupportedByHook () {
27+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .INTEGER );
28+
29+ assertThat (hookSupported ).isFalse ();
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ package dev .openfeature .sdk ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import dev .openfeature .sdk .fixtures .HookFixtures ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ class DoubleHookTest implements HookFixtures {
10+
11+ private Hook <Double > hook ;
12+
13+ @ BeforeEach
14+ void setupTest () {
15+ hook = mockDoubleHook ();
16+ }
17+
18+ @ Test
19+ void verifyFlagValueTypeIsSupportedByHook () {
20+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .DOUBLE );
21+
22+ assertThat (hookSupported ).isTrue ();
23+ }
24+
25+ @ Test
26+ void verifyFlagValueTypeIsNotSupportedByHook () {
27+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .STRING );
28+
29+ assertThat (hookSupported ).isFalse ();
30+ }
31+ }
Original file line number Diff line number Diff line change @@ -135,6 +135,19 @@ void mergeShouldRetainItsSubkeysWhenOverridingContextHasNoTargetingKey() {
135135 assertArrayEquals (new Object [] {"key1_1" }, value .keySet ().toArray ());
136136 }
137137
138+ @ DisplayName ("Merge should obtain keys from the overriding context when the existing context is empty" )
139+ @ Test
140+ void mergeShouldObtainKeysFromOverridingContextWhenExistingContextIsEmpty () {
141+ HashMap <String , Value > attributes = new HashMap <>();
142+ attributes .put ("key1" , new Value ("val1" ));
143+ attributes .put ("key2" , new Value ("val2" ));
144+
145+ EvaluationContext ctx = new ImmutableContext ();
146+ EvaluationContext overriding = new ImmutableContext (attributes );
147+ EvaluationContext merge = ctx .merge (overriding );
148+ assertArrayEquals (new Object [] {"key1" , "key2" }, merge .keySet ().toArray ());
149+ }
150+
138151 @ DisplayName ("Two different MutableContext objects with the different contents are not considered equal" )
139152 @ Test
140153 void unequalImmutableContextsAreNotEqual () {
Original file line number Diff line number Diff line change 1+ package dev .openfeature .sdk ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import dev .openfeature .sdk .fixtures .HookFixtures ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ class IntegerHookTest implements HookFixtures {
10+
11+ private Hook <Integer > hook ;
12+
13+ @ BeforeEach
14+ void setupTest () {
15+ hook = mockIntegerHook ();
16+ }
17+
18+ @ Test
19+ void verifyFlagValueTypeIsSupportedByHook () {
20+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .INTEGER );
21+
22+ assertThat (hookSupported ).isTrue ();
23+ }
24+
25+ @ Test
26+ void verifyFlagValueTypeIsNotSupportedByHook () {
27+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .STRING );
28+
29+ assertThat (hookSupported ).isFalse ();
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ package dev .openfeature .sdk ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import dev .openfeature .sdk .fixtures .HookFixtures ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ public class ObjectHookTest implements HookFixtures {
10+
11+ private Hook <Object > hook ;
12+
13+ @ BeforeEach
14+ void setupTest () {
15+ hook = mockObjectHook ();
16+ }
17+
18+ @ Test
19+ void verifyFlagValueTypeIsSupportedByHook () {
20+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .OBJECT );
21+
22+ assertThat (hookSupported ).isTrue ();
23+ }
24+
25+ @ Test
26+ void verifyFlagValueTypeIsNotSupportedByHook () {
27+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .INTEGER );
28+
29+ assertThat (hookSupported ).isFalse ();
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ package dev .openfeature .sdk ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import dev .openfeature .sdk .fixtures .HookFixtures ;
6+ import org .junit .jupiter .api .BeforeEach ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ class StringHookTest implements HookFixtures {
10+
11+ private Hook <String > hook ;
12+
13+ @ BeforeEach
14+ void setupTest () {
15+ hook = mockStringHook ();
16+ }
17+
18+ @ Test
19+ void verifyFlagValueTypeIsSupportedByHook () {
20+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .STRING );
21+
22+ assertThat (hookSupported ).isTrue ();
23+ }
24+
25+ @ Test
26+ void verifyFlagValueTypeIsNotSupportedByHook () {
27+ boolean hookSupported = hook .supportsFlagValueType (FlagValueType .INTEGER );
28+
29+ assertThat (hookSupported ).isFalse ();
30+ }
31+ }
Original file line number Diff line number Diff line change 66import dev .openfeature .sdk .DoubleHook ;
77import dev .openfeature .sdk .Hook ;
88import dev .openfeature .sdk .IntegerHook ;
9+ import dev .openfeature .sdk .ObjectHook ;
910import dev .openfeature .sdk .StringHook ;
1011
1112public interface HookFixtures {
@@ -26,6 +27,10 @@ default Hook<Double> mockDoubleHook() {
2627 return spy (DoubleHook .class );
2728 }
2829
30+ default Hook <Object > mockObjectHook () {
31+ return spy (ObjectHook .class );
32+ }
33+
2934 default Hook <?> mockGenericHook () {
3035 return spy (Hook .class );
3136 }
You can’t perform that action at this time.
0 commit comments