File tree 2 files changed +14
-20
lines changed
test/kotlin/test/tests/hashers
2 files changed +14
-20
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ package app.hashers
6
6
import app.FactCodes
7
7
import app.api.Api
8
8
import app.model.Author
9
+ import app.model.AuthorDistance
9
10
import app.model.Fact
10
11
import app.model.Repo
11
12
import io.reactivex.Observable
@@ -42,22 +43,20 @@ class AuthorDistanceHasher(
42
43
authorScores[email] = authorScores[email]!! + score
43
44
}
44
45
}, onError, {
45
- val stats = mutableListOf<Fact >()
46
- val author = Author (email = userEmails.toList()[0 ])
46
+ val stats = mutableListOf<AuthorDistance >()
47
47
authorScores.forEach { email, value ->
48
48
if (email !in userEmails) {
49
- stats.add(Fact (serverRepo, FactCodes .COLLEAGUES , value =
50
- email, value2 = value.toString(), author = author))
49
+ stats.add(AuthorDistance (serverRepo, email, value))
51
50
}
52
51
}
53
52
54
53
postDistancesToServer(stats)
55
54
})
56
55
}
57
56
58
- private fun postDistancesToServer (stats : List <Fact >) {
57
+ private fun postDistancesToServer (stats : List <AuthorDistance >) {
59
58
if (stats.isNotEmpty()) {
60
- api.postFacts (stats).onErrorThrow()
59
+ api.postAuthorDistances (stats).onErrorThrow()
61
60
}
62
61
}
63
62
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import app.api.MockApi
8
8
import app.hashers.AuthorDistanceHasher
9
9
import app.hashers.CommitCrawler
10
10
import app.model.Author
11
+ import app.model.AuthorDistance
11
12
import app.model.Fact
12
13
import app.model.Repo
13
14
import org.eclipse.jgit.api.Git
@@ -62,21 +63,15 @@ class AuthorDistanceHasherTest : Spek({
62
63
hashSetOf(author2.email)).updateFromObservable(observable,
63
64
onError = { _ -> fail("exception") })
64
65
65
- assertTrue(api.receivedFacts.contains(
66
- Fact (repo = serverRepo,
67
- code = FactCodes .COLLEAGUES ,
68
- author = author2,
69
- value = author1.email,
70
- value2 = (1.0).toString())
71
- ))
66
+ assertTrue(api.receivedDistances.contains(
67
+ AuthorDistance (repo = serverRepo,
68
+ email = author1.email,
69
+ score = 1.0)))
72
70
73
- assertTrue(api.receivedFacts.contains(
74
- Fact (repo = serverRepo,
75
- code = FactCodes .COLLEAGUES ,
76
- author = author2,
77
- value = author3.email,
78
- value2 = (0.0).toString())
79
- ))
71
+ assertTrue(api.receivedDistances.contains(
72
+ AuthorDistance (repo = serverRepo,
73
+ email = author3.email,
74
+ score = 0.0)))
80
75
}
81
76
82
77
afterGroup {
You can’t perform that action at this time.
0 commit comments