@@ -2,25 +2,30 @@ package tasks
2
2
3
3
import contributors.MockGithubService
4
4
import contributors.expectedConcurrentResults
5
- import contributors.expectedResults
6
5
import contributors.testRequestData
7
- import kotlinx.coroutines.ExperimentalCoroutinesApi
8
- import kotlinx.coroutines.test.runBlockingTest
6
+ import kotlinx.coroutines.runBlocking
9
7
import org.junit.Assert
10
8
import org.junit.Test
11
9
12
- @UseExperimental(ExperimentalCoroutinesApi ::class )
13
10
class Request5ConcurrentKtTest {
14
11
@Test
15
- fun testConcurrent () = runBlockingTest {
16
- val startTime = currentTime
12
+ fun testConcurrent () = runBlocking {
13
+ val startTime = System .currentTimeMillis()
17
14
val result = loadContributorsConcurrent(MockGithubService , testRequestData)
18
15
Assert .assertEquals(" Wrong result for 'loadContributorsConcurrent'" , expectedConcurrentResults.users, result)
19
- val virtualTime = currentTime - startTime
16
+ val totalTime = System .currentTimeMillis() - startTime
17
+ /*
18
+ // TODO: uncomment this assertion
20
19
Assert.assertEquals(
21
20
"The calls run concurrently, so the total virtual time should be 2200 ms: " +
22
- " 1000 for repos request plus max(1000, 1200, 800) = 1200 for contributors concurrent requests)" ,
23
- expectedConcurrentResults.timeFromStart, virtualTime
21
+ "1000 ms for repos request plus max(1000, 1200, 800) = 1200 ms for concurrent contributors requests)",
22
+ expectedConcurrentResults.timeFromStart, totalTime
23
+ )
24
+ */
25
+ Assert .assertTrue(
26
+ " The calls run concurrently, so the total virtual time should be 2200 ms: " +
27
+ " 1000 ms for repos request plus max(1000, 1200, 800) = 1200 ms for concurrent contributors requests)" ,
28
+ totalTime in expectedConcurrentResults.timeFromStart.. (expectedConcurrentResults.timeFromStart + 500 )
24
29
)
25
30
}
26
31
}
0 commit comments