88import dev .openfeature .sdk .NoOpTransactionContextPropagator ;
99import dev .openfeature .sdk .OpenFeatureAPI ;
1010import dev .openfeature .sdk .ThreadLocalTransactionContextPropagator ;
11- import dev .openfeature .sdk .isolated .OpenFeatureAPIFactory ;
1211import dev .openfeature .sdk .providers .memory .Flag ;
1312import dev .openfeature .sdk .providers .memory .InMemoryProvider ;
1413import java .util .Map ;
@@ -31,8 +30,8 @@ class IsolatedAPITest {
3130 @ Test
3231 @ DisplayName ("factory creates distinct API instances" )
3332 void factoryCreatesDistinctInstances () {
34- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
35- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
33+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
34+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
3635
3736 assertThat (api1 ).isInstanceOf (OpenFeatureAPI .class ).isNotSameAs (api2 );
3837 }
@@ -43,8 +42,8 @@ void factoryCreatesDistinctInstances() {
4342 @ Test
4443 @ DisplayName ("providers are isolated between instances" )
4544 void providerIsolation () {
46- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
47- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
45+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
46+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
4847
4948 InMemoryProvider provider = new InMemoryProvider (Map .of ());
5049 api1 .setProvider (provider );
@@ -59,8 +58,8 @@ void providerIsolation() {
5958 @ Test
6059 @ DisplayName ("hooks are isolated between instances" )
6160 void hookIsolation () {
62- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
63- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
61+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
62+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
6463
6564 api1 .addHooks (new NoOpHook ());
6665
@@ -74,8 +73,8 @@ void hookIsolation() {
7473 @ Test
7574 @ DisplayName ("evaluation context is isolated between instances" )
7675 void evaluationContextIsolation () {
77- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
78- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
76+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
77+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
7978
8079 api1 .setEvaluationContext (new ImmutableContext ("key-1" ));
8180 api2 .setEvaluationContext (new ImmutableContext ("key-2" ));
@@ -91,8 +90,8 @@ void evaluationContextIsolation() {
9190 @ Timeout (value = 2 , threadMode = Timeout .ThreadMode .SEPARATE_THREAD )
9291 @ DisplayName ("event handlers are isolated between instances" )
9392 void eventHandlerIsolation () throws Exception {
94- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
95- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
93+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
94+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
9695
9796 CountDownLatch api1HandlerLatch = new CountDownLatch (1 );
9897 AtomicBoolean api2HandlerCalled = new AtomicBoolean (false );
@@ -120,8 +119,8 @@ void eventHandlerIsolation() throws Exception {
120119 @ Test
121120 @ DisplayName ("transaction context propagator is isolated between instances" )
122121 void transactionContextPropagatorIsolation () {
123- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
124- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
122+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
123+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
125124
126125 ThreadLocalTransactionContextPropagator propagator = new ThreadLocalTransactionContextPropagator ();
127126 api1 .setTransactionContextPropagator (propagator );
@@ -137,7 +136,7 @@ void transactionContextPropagatorIsolation() {
137136 @ Test
138137 @ DisplayName ("isolated instance conforms to API contract" )
139138 void isolatedInstanceConformsToAPIContract () throws Exception {
140- OpenFeatureAPI api = OpenFeatureAPIFactory . createAPI ();
139+ OpenFeatureAPI api = OpenFeatureAPI . createIsolated ();
141140
142141 // provider management
143142 InMemoryProvider provider = new InMemoryProvider (Map .of (
@@ -172,8 +171,8 @@ void isolatedInstanceConformsToAPIContract() throws Exception {
172171 @ Test
173172 @ DisplayName ("clearHooks does not affect other instances" )
174173 void clearHooksDoesNotAffectOtherInstances () {
175- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
176- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
174+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
175+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
177176
178177 NoOpHook hook = new NoOpHook ();
179178 api1 .addHooks (hook );
@@ -192,8 +191,8 @@ void clearHooksDoesNotAffectOtherInstances() {
192191 @ Test
193192 @ DisplayName ("clients use their own instance's provider" )
194193 void clientUsesItsOwnInstanceProvider () throws Exception {
195- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
196- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
194+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
195+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
197196
198197 api1 .setProviderAndWait (new InMemoryProvider (Map .of (
199198 "flag1" ,
@@ -221,8 +220,8 @@ void warnWhenProviderBoundToMultipleInstances() {
221220 Logger mockLogger = Mockito .mock (Logger .class );
222221 LoggerMock .setMock (OpenFeatureAPI .class , mockLogger );
223222 try {
224- OpenFeatureAPI api1 = OpenFeatureAPIFactory . createAPI ();
225- OpenFeatureAPI api2 = OpenFeatureAPIFactory . createAPI ();
223+ OpenFeatureAPI api1 = OpenFeatureAPI . createIsolated ();
224+ OpenFeatureAPI api2 = OpenFeatureAPI . createIsolated ();
226225
227226 NoOpProvider provider = new NoOpProvider ();
228227 api1 .setProvider (provider );
0 commit comments