22
33import com .switcherapi .SwitchersBase ;
44import com .switcherapi .client .model .Switcher ;
5- import com .switcherapi .client .model .SwitcherBuilder ;
65import com .switcherapi .fixture .CountDownHelper ;
76import com .switcherapi .fixture .MockWebServerHelper ;
8- import mockwebserver3 .QueueDispatcher ;
97import org .junit .jupiter .api .AfterAll ;
108import org .junit .jupiter .api .BeforeAll ;
11- import org .junit .jupiter .api .BeforeEach ;
129import org .junit .jupiter .api .Test ;
1310
1411import java .io .IOException ;
1714import static org .junit .jupiter .api .Assertions .assertFalse ;
1815import static org .junit .jupiter .api .Assertions .assertTrue ;
1916
20- class SwitcherThrottleTest extends MockWebServerHelper {
17+ class SwitcherThrottle1Test extends MockWebServerHelper {
2118
2219 @ BeforeAll
2320 static void setup () throws IOException {
@@ -30,19 +27,15 @@ static void setup() throws IOException {
3027 .domain ("TEST_DOMAIN" )
3128 .component ("TEST_COMPONENT" )
3229 .environment (DEFAULT_ENV ));
30+
31+ SwitchersBase .initializeClient ();
3332 }
3433
3534 @ AfterAll
3635 static void tearDown () {
3736 MockWebServerHelper .tearDownMockServer ();
3837 }
3938
40- @ BeforeEach
41- void resetSwitcherContextState () {
42- ((QueueDispatcher ) mockBackEnd .getDispatcher ()).clear ();
43- SwitchersBase .initializeClient ();
44- }
45-
4639 @ Test
4740 void shouldReturnTrue_withThrottle () {
4841 // Initial remote call
@@ -68,27 +61,4 @@ void shouldReturnTrue_withThrottle() {
6861 assertFalse (switcher .isItOn ());
6962 }
7063
71- @ Test
72- void shouldRetrieveNewResponse_whenStrategyInputChanged () {
73- // Initial remote call
74- givenResponse (generateMockAuth (10 )); //auth
75- givenResponse (generateCriteriaResponse ("true" , false )); //criteria - sync (cached)
76- givenResponse (generateCriteriaResponse ("false" , false )); //criteria - async (cached)
77-
78- // Throttle period - should use cache
79- givenResponse (generateCriteriaResponse ("false" , false )); //criteria - async after 1 sec (background)
80-
81- //test
82- SwitcherBuilder switcher = SwitchersBase
83- .getSwitcher (SwitchersBase .USECASE11 )
84- .flush ()
85- .throttle (1000 );
86-
87- for (int i = 0 ; i < 100 ; i ++) {
88- assertTrue (switcher .checkValue ("value" ).isItOn ());
89- }
90-
91- assertFalse (switcher .checkValue ("value_changed" ).isItOn ());
92- }
93-
9464}
0 commit comments