5
5
import dev .openfeature .sdk .EventDetails ;
6
6
import dev .openfeature .sdk .ImmutableContext ;
7
7
import dev .openfeature .sdk .OpenFeatureAPI ;
8
+ import dev .openfeature .sdk .ProviderState ;
8
9
import dev .openfeature .sdk .Value ;
9
10
import dev .openfeature .sdk .exceptions .FlagNotFoundError ;
10
11
import dev .openfeature .sdk .exceptions .ProviderNotReadyError ;
27
28
import static org .junit .jupiter .api .Assertions .assertEquals ;
28
29
import static org .junit .jupiter .api .Assertions .assertThrows ;
29
30
import static org .junit .jupiter .api .Assertions .assertTrue ;
31
+ import static org .awaitility .Awaitility .await ;
30
32
import static org .mockito .ArgumentMatchers .any ;
31
33
import static org .mockito .ArgumentMatchers .argThat ;
32
34
import static org .mockito .Mockito .mock ;
@@ -45,15 +47,16 @@ class InMemoryProviderTest {
45
47
void beforeEach () {
46
48
Map <String , Flag <?>> flags = buildFlags ();
47
49
provider = spy (new InMemoryProvider (flags ));
48
- OpenFeatureAPI .getInstance ().onProviderConfigurationChanged (eventDetails -> {});
50
+ OpenFeatureAPI .getInstance ().onProviderConfigurationChanged (eventDetails -> {
51
+ });
49
52
OpenFeatureAPI .getInstance ().setProviderAndWait (provider );
50
53
client = OpenFeatureAPI .getInstance ().getClient ();
51
54
provider .updateFlags (flags );
52
55
provider .updateFlag ("addedFlag" , Flag .builder ()
53
- .variant ("on" , true )
54
- .variant ("off" , false )
55
- .defaultVariant ("on" )
56
- .build ());
56
+ .variant ("on" , true )
57
+ .variant ("off" , false )
58
+ .defaultVariant ("on" )
59
+ .build ());
57
60
}
58
61
59
62
@ SneakyThrows
@@ -85,10 +88,9 @@ void getDoubleEvaluation() {
85
88
@ Test
86
89
void getObjectEvaluation () {
87
90
Value expectedObject = new Value (mapToStructure (ImmutableMap .of (
88
- "showImages" , new Value (true ),
89
- "title" , new Value ("Check out these pics!" ),
90
- "imagesPerPage" , new Value (100 )
91
- )));
91
+ "showImages" , new Value (true ),
92
+ "title" , new Value ("Check out these pics!" ),
93
+ "imagesPerPage" , new Value (100 ))));
92
94
assertEquals (expectedObject , client .getObjectValue ("object-flag" , new Value (true )));
93
95
}
94
96
@@ -112,7 +114,8 @@ void shouldThrowIfNotInitialized() {
112
114
InMemoryProvider inMemoryProvider = new InMemoryProvider (new HashMap <>());
113
115
114
116
// ErrorCode.PROVIDER_NOT_READY should be returned when evaluated via the client
115
- assertThrows (ProviderNotReadyError .class , ()-> inMemoryProvider .getBooleanEvaluation ("fail_not_initialized" , false , new ImmutableContext ()));
117
+ assertThrows (ProviderNotReadyError .class ,
118
+ () -> inMemoryProvider .getBooleanEvaluation ("fail_not_initialized" , false , new ImmutableContext ()));
116
119
}
117
120
118
121
@ SuppressWarnings ("unchecked" )
@@ -126,8 +129,8 @@ void emitChangedFlagsOnlyIfThereAreChangedFlags() {
126
129
127
130
provider .updateFlags (flags );
128
131
129
- verify (handler , times (1 ))
130
- .accept (argThat (details -> details .getFlagsChanged ().isEmpty ()));
132
+ await (). untilAsserted (() -> verify (handler , times (1 ))
133
+ .accept (argThat (details -> details .getFlagsChanged ().isEmpty ()))) ;
131
134
}
132
135
133
136
@ Test
0 commit comments