Skip to content

Commit d37315d

Browse files
committed
rename rightAssertedJiraClientError to orFail
1 parent b97687f commit d37315d

File tree

10 files changed

+37
-37
lines changed

10 files changed

+37
-37
lines changed

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/JiraCommentOperatorTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
package com.linkedplanet.kotlinjiraclient
2121

22-
import com.linkedplanet.kotlinjiraclient.util.rightAssertedJiraClientError
22+
import com.linkedplanet.kotlinjiraclient.util.orFail
2323
import kotlinx.coroutines.runBlocking
2424
import org.hamcrest.CoreMatchers.equalTo
2525
import org.hamcrest.CoreMatchers.notNullValue
@@ -43,7 +43,7 @@ interface JiraCommentOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFi
4343

4444
val comments = runBlocking {
4545
commentOperator.getComments(issue.key)
46-
}.rightAssertedJiraClientError()
46+
}.orFail()
4747

4848
assertThat(comments, notNullValue())
4949
assertThat(comments.size, equalTo(0))
@@ -56,7 +56,7 @@ interface JiraCommentOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFi
5656

5757
val comments = runBlocking {
5858
commentOperator.getComments(issue.key)
59-
}.rightAssertedJiraClientError()
59+
}.orFail()
6060

6161
assertThat(comments, notNullValue())
6262
assertThat(comments.size, equalTo(1))
@@ -76,9 +76,9 @@ interface JiraCommentOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFi
7676
commentToUpdate.id,
7777
"Test-Update"
7878
)
79-
}.rightAssertedJiraClientError()
79+
}.orFail()
8080

81-
val comments = runBlocking { commentOperator.getComments(issue.key) }.rightAssertedJiraClientError()
81+
val comments = runBlocking { commentOperator.getComments(issue.key) }.orFail()
8282
assertThat(comments.size, equalTo(1))
8383
val comment = comments.first()
8484

@@ -90,10 +90,10 @@ interface JiraCommentOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFi
9090
fun comments_05DeleteComment() {
9191
val (issue, commentToDelete) = jiraCommentTestHelper.createIssueWithComment("comments_05DeleteComment")
9292

93-
runBlocking { commentOperator.deleteComment(issue.key, commentToDelete.id) }.rightAssertedJiraClientError()
93+
runBlocking { commentOperator.deleteComment(issue.key, commentToDelete.id) }.orFail()
9494

9595
val commentsAfterDeletion =
96-
runBlocking { commentOperator.getComments(issue.key) }.rightAssertedJiraClientError()
96+
runBlocking { commentOperator.getComments(issue.key) }.orFail()
9797
assertThat(commentsAfterDeletion.size, equalTo(0))
9898
}
9999
}

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/JiraIssueLinkOperatorTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
package com.linkedplanet.kotlinjiraclient
2121

22-
import com.linkedplanet.kotlinjiraclient.util.rightAssertedJiraClientError
22+
import com.linkedplanet.kotlinjiraclient.util.orFail
2323
import kotlinx.coroutines.runBlocking
2424
import org.hamcrest.CoreMatchers.equalTo
2525
import org.hamcrest.MatcherAssert.assertThat
@@ -39,7 +39,7 @@ interface JiraIssueLinkOperatorTest<JiraFieldType> : BaseTestConfigProvider<Jira
3939
outward.key,
4040
"Relates"
4141
)
42-
}.rightAssertedJiraClientError()
42+
}.orFail()
4343

4444
// Check
4545
val issueLinks = jiraIssueLinkTestHelper.getIssueLinks(inward.key)
@@ -51,7 +51,7 @@ interface JiraIssueLinkOperatorTest<JiraFieldType> : BaseTestConfigProvider<Jira
5151
assertThat(outwardIssue.get("key").asString, equalTo(outward.key))
5252

5353
// Delete
54-
runBlocking { issueLinkOperator.deleteIssueLink(issueLinkId) }.rightAssertedJiraClientError()
54+
runBlocking { issueLinkOperator.deleteIssueLink(issueLinkId) }.orFail()
5555

5656
// Check
5757
val issueLinksAfterDeletion = jiraIssueLinkTestHelper.getIssueLinks(inward.key)

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/JiraIssueOperatorTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface JiraIssueOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFiel
4040
Either.Right(jsonObject.getAsJsonPrimitive("key").asString)
4141
}
4242

43-
existingIssueIds.rightAssertedJiraClientError().forEach {
43+
existingIssueIds.orFail().forEach {
4444
issueOperator.deleteIssue(it)
4545
}
4646

@@ -222,12 +222,12 @@ interface JiraIssueOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFiel
222222
issueTypeId,
223223
fields
224224
)
225-
}.rightAssertedJiraClientError()
225+
}.orFail()
226226
assertThat(creationResponse.self.endsWith("/rest/api/2/issue/${creationResponse.id}"), equalTo(true))
227227

228228
val createdIssue = runBlocking {
229229
issueOperator.getIssueByJQL("key = \"${creationResponse.key}\"", ::issueParser)
230-
}.rightAssertedJiraClientError()
230+
}.orFail()
231231

232232
assertThat(createdIssue.projectId, equalTo(projectId))
233233
assertThat(createdIssue.issueTypeId, equalTo(issueTypeId))
@@ -263,7 +263,7 @@ interface JiraIssueOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFiel
263263

264264
val issue = runBlocking {
265265
issueOperator.getIssueByJQL("summary ~ \"MyNewSummary\"", ::issueParser)
266-
}.rightAssertedJiraClientError()
266+
}.orFail()
267267

268268
val summary = "MyNewSummary-update"
269269
val description = "MyDescription-update"
@@ -300,11 +300,11 @@ interface JiraIssueOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFiel
300300
fieldFactory.jiraCustomInsightObjectsField("InsightObjects", insightObjectsKeys)
301301
)
302302
)
303-
}.rightAssertedJiraClientError()
303+
}.orFail()
304304

305305
val issueAfterUpdate = runBlocking {
306306
issueOperator.getIssueByKey(issue.key, ::issueParser)
307-
}.rightAssertedJiraClientError()
307+
}.orFail()
308308

309309
assertThat(issueAfterUpdate.projectId, equalTo(projectId))
310310
assertThat(issueAfterUpdate.issueTypeId, equalTo(issueTypeId))
@@ -328,11 +328,11 @@ interface JiraIssueOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraFiel
328328

329329
val searchNewIssue = runBlocking {
330330
issueOperator.getIssueByJQL("summary ~ \"MyNewSummary-update\"", ::issueParser)
331-
}.rightAssertedJiraClientError()
331+
}.orFail()
332332

333333
runBlocking {
334334
issueOperator.deleteIssue(searchNewIssue.key)
335-
}.rightAssertedJiraClientError()
335+
}.orFail()
336336

337337
val issuesAfterDeletion = runBlocking {
338338
issueOperator.getIssueByKey(searchNewIssue.key, ::issueParser).orNull()

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/JiraIssueTypeOperatorTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlinjiraclient
2121

2222
import com.linkedplanet.kotlinjiraclient.api.model.JiraIssueTypeAttribute
23-
import com.linkedplanet.kotlinjiraclient.util.rightAssertedJiraClientError
23+
import com.linkedplanet.kotlinjiraclient.util.orFail
2424
import kotlinx.coroutines.runBlocking
2525
import org.hamcrest.CoreMatchers.equalTo
2626
import org.hamcrest.MatcherAssert.assertThat
@@ -31,13 +31,13 @@ interface JiraIssueTypeOperatorTest<JiraFieldType> : BaseTestConfigProvider<Jira
3131
@Test
3232
fun issueTypes_01GetIssueTypes() {
3333
val issueTypeNames = listOf("Bug", "Epic", "Story", "Sub-task", "Task")
34-
val issueTypes = runBlocking { issueTypeOperator.getIssueTypes(projectId) }.rightAssertedJiraClientError()
34+
val issueTypes = runBlocking { issueTypeOperator.getIssueTypes(projectId) }.orFail()
3535
assertThat(issueTypes.map { it.name }.toSet(), equalTo(issueTypeNames.toSet()))
3636
}
3737

3838
@Test
3939
fun issueTypes_02GetIssueType() {
40-
val issueType = runBlocking { issueTypeOperator.getIssueType(issueTypeId) }.rightAssertedJiraClientError()
40+
val issueType = runBlocking { issueTypeOperator.getIssueType(issueTypeId) }.orFail()
4141
assertThat(issueType.id, equalTo(issueTypeId.toString()))
4242
assertThat(issueType.name, equalTo("Story"))
4343
}
@@ -50,7 +50,7 @@ interface JiraIssueTypeOperatorTest<JiraFieldType> : BaseTestConfigProvider<Jira
5050
projectId,
5151
issueTypeId
5252
)
53-
}.rightAssertedJiraClientError()
53+
}.orFail()
5454
val expectedAttributes = listOf(
5555
"Epic Link", "Summary", "Issue Type", "Reporter", "Component/s", "Description",
5656
"Fix Version/s", "Priority", "Labels", "Attachment", "Linked Issues", "Assignee",

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/JiraProjectOperatorTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
package com.linkedplanet.kotlinjiraclient
2121

22-
import com.linkedplanet.kotlinjiraclient.util.rightAssertedJiraClientError
22+
import com.linkedplanet.kotlinjiraclient.util.orFail
2323
import kotlinx.coroutines.runBlocking
2424
import org.hamcrest.CoreMatchers.equalTo
2525
import org.hamcrest.MatcherAssert.assertThat
@@ -31,7 +31,7 @@ interface JiraProjectOperatorTest<JiraFieldType>: BaseTestConfigProvider<JiraFie
3131
fun projects_01GetProjects() {
3232
val projects = runBlocking {
3333
projectOperator.getProjects()
34-
}.rightAssertedJiraClientError()
34+
}.orFail()
3535

3636
assertThat(projects.size, equalTo(1))
3737
assertThat(projects.first().id, equalTo("10000"))
@@ -43,7 +43,7 @@ interface JiraProjectOperatorTest<JiraFieldType>: BaseTestConfigProvider<JiraFie
4343
fun projects_02GetProject() {
4444
val project = runBlocking {
4545
projectOperator.getProject(projectId)
46-
}.rightAssertedJiraClientError()
46+
}.orFail()
4747

4848
assertThat(project.id, equalTo("10000"))
4949
assertThat(project.key, equalTo("TEST"))

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/JiraUserOperatorTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package com.linkedplanet.kotlinjiraclient
2121

2222
import com.linkedplanet.kotlinjiraclient.util.JiraUserTestHelper
23-
import com.linkedplanet.kotlinjiraclient.util.rightAssertedJiraClientError
23+
import com.linkedplanet.kotlinjiraclient.util.orFail
2424
import kotlinx.coroutines.runBlocking
2525
import org.hamcrest.CoreMatchers.equalTo
2626
import org.hamcrest.MatcherAssert.assertThat
@@ -30,7 +30,7 @@ interface JiraUserOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraField
3030

3131
@Test
3232
fun users_01GetUsersByProjectKey() {
33-
val users = runBlocking { userOperator.getUsersByProjectKey(projectKey) }.rightAssertedJiraClientError()
33+
val users = runBlocking { userOperator.getUsersByProjectKey(projectKey) }.orFail()
3434
assertThat(users.size, equalTo(2))
3535

3636
val admin = users.firstOrNull { it.name == "admin" }
@@ -43,7 +43,7 @@ interface JiraUserOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraField
4343
@Test
4444
fun users_02GetAssignableUsersByProjectKey() {
4545
val users =
46-
runBlocking { userOperator.getAssignableUsersByProjectKey(projectKey) }.rightAssertedJiraClientError()
46+
runBlocking { userOperator.getAssignableUsersByProjectKey(projectKey) }.orFail()
4747
assertThat(users.size, equalTo(3))
4848

4949
val admin = users.firstOrNull { it.name == "admin" }
@@ -58,7 +58,7 @@ interface JiraUserOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraField
5858

5959
@Test
6060
fun users_03GetProjectAdminUsers() {
61-
val users = runBlocking { userOperator.getProjectAdminUsers(projectKey) }.rightAssertedJiraClientError()
61+
val users = runBlocking { userOperator.getProjectAdminUsers(projectKey) }.orFail()
6262
assertThat(users.size, equalTo(1))
6363

6464
val admin = users.firstOrNull { it.name == "admin" }
@@ -67,7 +67,7 @@ interface JiraUserOperatorTest<JiraFieldType> : BaseTestConfigProvider<JiraField
6767

6868
@Test
6969
fun users_04GetSystemAdminUsers() {
70-
val users = runBlocking { userOperator.getSystemAdminUsers() }.rightAssertedJiraClientError()
70+
val users = runBlocking { userOperator.getSystemAdminUsers() }.orFail()
7171
assertThat(users.size, equalTo(1))
7272

7373
val admin = users.firstOrNull { it.name == "admin" }

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/util/AssertionExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.linkedplanet.kotlinjiraclient.api.error.JiraClientError
2424
import org.junit.Assert.fail
2525

2626

27-
internal fun <R> Either<JiraClientError, R?>.rightAssertedJiraClientError(): R {
27+
internal fun <R> Either<JiraClientError, R?>.orFail(): R {
2828
this.mapLeft {
2929
fail("Unexpected JiraClientError: ${it.error} - ${it.message}")
3030
}

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/util/JiraCommentTestHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class JiraCommentTestHelper<JiraFieldType>(
3636
fun createIssueWithComment(testName: String): Pair<JiraIssue, JiraIssueComment> {
3737
val issue = jiraIssueTestHelper.createDefaultIssue(fieldFactory.jiraSummaryField("$testName ticket"))
3838

39-
runBlocking { commentOperator.createComment(issue.key, testName) }.rightAssertedJiraClientError()
39+
runBlocking { commentOperator.createComment(issue.key, testName) }.orFail()
4040
val commentsBeforeUpdate =
41-
runBlocking { commentOperator.getComments(issue.key) }.rightAssertedJiraClientError()
41+
runBlocking { commentOperator.getComments(issue.key) }.orFail()
4242
assertThat(commentsBeforeUpdate.size, equalTo(1))
4343
val commentToUpdate = commentsBeforeUpdate.first()
4444
return Pair(issue, commentToUpdate)

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/util/JiraIssueTestHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class JiraIssueTestHelper<JiraFieldType>(
5050
fieldFactory.jiraIssueTypeField(jiraIssueTypeId),
5151
).plus(fields)
5252
issueOperator.createIssue(projectId, jiraIssueTypeId, combinedFields)
53-
}.rightAssertedJiraClientError()
53+
}.orFail()
5454

5555
fun getIssueByKey(key: String) = runBlocking {
5656
issueOperator.getIssueByKey(key, ::issueParser)
57-
}.rightAssertedJiraClientError()
57+
}.orFail()
5858
}
5959

6060
data class Story(

kotlin-jira-client/kotlin-jira-client-test-base/src/main/kotlin/com/linkedplanet/kotlinjiraclient/util/JiraTransitionTestHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class JiraTransitionTestHelper(
2828

2929
fun getAvailableTransitions(issueKey: String) = runBlocking {
3030
transitionOperator.getAvailableTransitions(issueKey)
31-
}.rightAssertedJiraClientError()
31+
}.orFail()
3232

3333
fun doTransition(issueKey: String, transitionId: String) = runBlocking {
3434
transitionOperator.doTransition(issueKey, transitionId)
35-
}.rightAssertedJiraClientError()
35+
}.orFail()
3636
}

0 commit comments

Comments
 (0)