@@ -295,7 +295,7 @@ class DVCClientTests {
295295 waitForOpenLatch(initializeLatch, 2000 , TimeUnit .MILLISECONDS )
296296
297297 val i = AtomicInteger (0 )
298- val callbackLatch = CountDownLatch (5 )
298+ val callbackLatch = CountDownLatch (6 )
299299
300300 val callback = object : DVCCallback <Map <String , BaseConfigVariable >> {
301301 override fun onSuccess (result : Map <String , BaseConfigVariable >) {
@@ -311,12 +311,12 @@ class DVCClientTests {
311311 }
312312 }
313313
314- client.identifyUser(DVCUser .builder().withUserId(" new_userid " ).build(), callback)
315- client.identifyUser(DVCUser .builder().withUserId(" new_userid1 " ).build(), callback)
316- client.identifyUser(DVCUser .builder().withUserId(" new_userid2 " ).build(), callback)
317- client.identifyUser(DVCUser .builder().withUserId(" new_userid3 " ).build(), callback)
318- client.identifyUser(DVCUser .builder().withUserId(" new_userid4 " ).build(), callback)
319- client.identifyUser(DVCUser .builder().withUserId(" new_userid5 " ).build(), callback)
314+ client.identifyUser(DVCUser .builder().withUserId(" expected_userid1 " ).build(), callback)
315+ client.identifyUser(DVCUser .builder().withUserId(" random_user1 " ).build(), callback)
316+ client.identifyUser(DVCUser .builder().withUserId(" random_user2 " ).build(), callback)
317+ client.identifyUser(DVCUser .builder().withUserId(" random_user3 " ).build(), callback)
318+ client.identifyUser(DVCUser .builder().withUserId(" random_user4 " ).build(), callback)
319+ client.identifyUser(DVCUser .builder().withUserId(" expected_userid2 " ).build(), callback)
320320
321321 waitForOpenLatch(callbackLatch, 5000 , TimeUnit .MILLISECONDS )
322322
@@ -328,9 +328,7 @@ class DVCClientTests {
328328 } else {
329329 // expect only the first and last user id to be sent as a result of the identify calls
330330 try {
331- Assertions .assertTrue(it.path?.contains(" new_userid5" ) == true ||
332- it.path?.contains(" new_userid&" ) == true
333- )
331+ Assertions .assertEquals(true , it.path?.contains(" expected_userid" ))
334332 } catch (e: org.opentest4j.AssertionFailedError ) {
335333 println (it.path)
336334 throw e
@@ -406,6 +404,14 @@ class DVCClientTests {
406404 countDownLatch.countDown()
407405 }
408406 })
407+ client.onInitialized(object : DVCCallback <String > {
408+ override fun onSuccess (result : String ) {
409+ client.identifyUser(DVCUser .builder().withUserId(" asdasdas" ).build())
410+ }
411+ override fun onError (t : Throwable ) {
412+ error = t
413+ }
414+ })
409415 } catch (t: Throwable ) {
410416 countDownLatch.countDown()
411417 } finally {
@@ -430,6 +436,15 @@ class DVCClientTests {
430436 calledBack = true
431437 countDownLatch.countDown()
432438 }
439+
440+ client.onInitialized(object : DVCCallback <String > {
441+ override fun onSuccess (result : String ) {
442+ client.identifyUser(DVCUser .builder().withUserId(" asdasdas" ).build())
443+ }
444+ override fun onError (t : Throwable ) {
445+ error = t
446+ }
447+ })
433448 } catch (t: Throwable ) {
434449 countDownLatch.countDown()
435450 } finally {
@@ -441,7 +456,7 @@ class DVCClientTests {
441456
442457 @Test
443458 fun `variable calls back when variable value has changed for json object` () {
444- val config = generateJSONObjectConfig(" activate-flag" , JSONObject (mapOf (" test " to " value " )))
459+ val config = generateJSONObjectConfig(" activate-flag" , JSONObject (mapOf (" test1 " to " value1 " )))
445460 val config2 = generateJSONObjectConfig(" activate-flag" , JSONObject (mapOf (" test2" to " value2" )))
446461
447462 mockWebServer.enqueue(MockResponse ().setResponseCode(200 ).setBody(objectMapper.writeValueAsString(config)))
@@ -455,7 +470,7 @@ class DVCClientTests {
455470 val countDownLatch = CountDownLatch (2 )
456471 val initializedLatch = CountDownLatch (1 )
457472
458- val variable = client.variable(" activate-flag" , JSONObject (mapOf (" arg " to " yeah " )))
473+ val variable = client.variable(" activate-flag" , JSONObject (mapOf (" test " to " default " )))
459474 variable.onUpdate {
460475 countDownLatch.countDown()
461476 }
@@ -470,9 +485,8 @@ class DVCClientTests {
470485 }
471486 })
472487
473- Assertions .assertEquals(variable.value.getString(" arg" ), " yeah" )
474488 initializedLatch.await(2000 , TimeUnit .MILLISECONDS )
475- Assertions .assertEquals(variable.value.getString(" test " ), " value " )
489+ Assertions .assertEquals(variable.value.getString(" test1 " ), " value1 " )
476490
477491 countDownLatch.await(3000 , TimeUnit .MILLISECONDS )
478492 Assertions .assertEquals(variable.value.getString(" test2" ), " value2" )
0 commit comments