Skip to content

Commit a33856e

Browse files
committed
remove some kotlin style warnings
1 parent c6559fb commit a33856e

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

kotlin-insight-client/kotlin-insight-client-test-base/src/main/kotlin/com/linkedplanet/kotlininsightclient/InsightHistoryOperatorTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ interface InsightHistoryOperatorTest {
3535
@Test
3636
fun testHistory() {
3737
runBlocking {
38-
val country = insightObjectOperator.getObjectByName(InsightObjectType.Country.id, "Germany", ::identity).orNull()!!
39-
val history = insightHistoryOperator.getHistory(country.id).orNull()!!
38+
val country =
39+
insightObjectOperator.getObjectByName(InsightObjectType.Country.id, "Germany", ::identity).getOrNull()!!
40+
val history = insightHistoryOperator.getHistory(country.id).getOrNull()!!
4041
assertThat(history.historyItems.isNotEmpty(), equalTo(true))
4142
assertThat(history.historyItems.last().actor.key, equalTo("admin"))
4243
assertThat(history.historyItems.last().created, endsWith("Z"))

kotlin-insight-client/kotlin-insight-client-test-base/src/main/kotlin/com/linkedplanet/kotlininsightclient/TestUtils.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ import org.hamcrest.MatcherAssert.assertThat
3333
*/
3434
fun <T> Either<InsightClientError, T>.orFail(): T {
3535
when (this) {
36-
is Either.Left<InsightClientError> -> assertThat(this.value.message+" error:"+this.value.error, equalTo("No Error at all!"))
36+
is Either.Left<InsightClientError> -> assertThat(
37+
"${this.value.message} error:${this.value.error}",
38+
equalTo("No Error at all!")
39+
)
40+
3741
is Either.Right -> return this.value
3842
}
39-
return (this as Either<InsightClientError, T>).orNull()!!
43+
return (this as Either<InsightClientError, T>).getOrNull()!!
4044
}
4145

4246
fun <T> Either<InsightClientError, T>.asError(): InsightClientError = when (this) {

kotlin-insight-client/kotlin-insight-client-test-base/src/main/kotlin/com/linkedplanet/kotlininsightclient/repositories/CompanyRepositoryBasedOnNameMapping.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CompanyRepositoryBasedOnNameMapping(
4949
override suspend fun referenceAttributeToValue(attribute: InsightAttribute): Any? {
5050
val country = (attribute as InsightAttribute.Reference).referencedObjects.first().id
5151
val eitherCountry = countryOperator.getById(country)
52-
return eitherCountry.orNull()
52+
return eitherCountry.getOrNull()
5353
}
5454

5555
override suspend fun attributeToReferencedObjectId(
@@ -63,7 +63,7 @@ class CompanyRepositoryBasedOnNameMapping(
6363
name = country.name,
6464
toDomain = ::identity
6565
)
66-
.orNull()?.id
66+
.getOrNull()?.id
6767
)
6868
}
6969

kotlin-insight-client/kotlin-insight-client-test-base/src/main/kotlin/com/linkedplanet/kotlininsightclient/repositories/TestsWithListRepositoryBasedOnNameMapping.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class TestsWithListRepositoryBasedOnNameMapping(
4949

5050
override suspend fun referenceAttributeToValue(attribute: InsightAttribute): Any? {
5151
val listOfObjects = (attribute as? InsightAttribute.Reference)?.referencedObjects
52-
?.mapNotNull { simpleObjectRepository.getById(it.id).orNull() }
52+
?.mapNotNull { simpleObjectRepository.getById(it.id).getOrNull() }
5353
return listOfObjects
5454
}
5555

0 commit comments

Comments
 (0)