Skip to content

Commit

Permalink
Merge pull request EventFahrplan#623 from EventFahrplan/assertion-lib…
Browse files Browse the repository at this point in the history
…rary-update

Migrate remaining tests from AssertJ to Truth.
  • Loading branch information
johnjohndoe authored Feb 16, 2024
2 parents 6050264 + b6ff460 commit 8b680e0
Show file tree
Hide file tree
Showing 32 changed files with 71 additions and 83 deletions.
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ dependencies {

testImplementation project(":commons-testing")
testImplementation Libs.annotation
testImplementation(Libs.assertjAndroid) {
exclude group: "com.android.support", module: "support-annotations"
}
testImplementation Libs.coreTesting
testImplementation Libs.junitJupiterApi
testRuntimeOnly Libs.junitJupiterEngine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nerd.tuxmobil.fahrplan.congress.alarms

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import info.metadude.android.eventfahrplan.commons.testing.verifyInvokedNever
import info.metadude.android.eventfahrplan.commons.testing.verifyInvokedOnce
Expand All @@ -8,7 +9,6 @@ import nerd.tuxmobil.fahrplan.congress.alarms.AlarmUpdater.OnAlarmUpdateListener
import nerd.tuxmobil.fahrplan.congress.preferences.SharedPreferencesRepository
import nerd.tuxmobil.fahrplan.congress.repositories.AppRepository
import nerd.tuxmobil.fahrplan.congress.utils.ConferenceTimeFrame
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.kotlin.doReturn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nerd.tuxmobil.fahrplan.congress.dataconverters

import com.google.common.truth.Truth.assertThat
import nerd.tuxmobil.fahrplan.congress.models.Alarm
import nerd.tuxmobil.fahrplan.congress.models.SchedulableAlarm
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import info.metadude.android.eventfahrplan.database.models.Alarm as AlarmDatabaseModel

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nerd.tuxmobil.fahrplan.congress.dataconverters

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.network.models.HttpHeader
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import info.metadude.android.eventfahrplan.network.fetching.FetchScheduleResult as NetworkFetchScheduleResult
import info.metadude.android.eventfahrplan.network.fetching.HttpStatus as NetworkHttpStatus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nerd.tuxmobil.fahrplan.congress.dataconverters

import com.google.common.truth.Truth.assertThat
import nerd.tuxmobil.fahrplan.congress.models.Highlight
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import info.metadude.android.eventfahrplan.database.models.Highlight as HighlightDatabaseModel

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package nerd.tuxmobil.fahrplan.congress.dataconverters

import org.assertj.core.api.Assertions.assertThat
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
import org.threeten.bp.ZoneId
import info.metadude.android.eventfahrplan.database.models.HttpHeader as HttpHeaderDatabaseModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package nerd.tuxmobil.fahrplan.congress.dataconverters

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import info.metadude.android.eventfahrplan.database.models.Highlight
import info.metadude.android.eventfahrplan.database.models.Session.Companion.RECORDING_OPT_OUT_ON
import nerd.tuxmobil.fahrplan.congress.models.DateInfo
import nerd.tuxmobil.fahrplan.congress.models.Session
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.threeten.bp.ZoneOffset
import info.metadude.android.eventfahrplan.database.models.Session as SessionDatabaseModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package nerd.tuxmobil.fahrplan.congress.dataconverters

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.DayRange
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import info.metadude.kotlin.library.engelsystem.models.Shift
import nerd.tuxmobil.fahrplan.congress.NoLogging
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.threeten.bp.ZoneOffset
import org.threeten.bp.ZonedDateTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package nerd.tuxmobil.fahrplan.congress.dataconverters

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.DayRange
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import info.metadude.kotlin.library.engelsystem.models.Shift
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.threeten.bp.ZoneOffset
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nerd.tuxmobil.fahrplan.congress.models

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class DateInfoTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nerd.tuxmobil.fahrplan.congress.models

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.DayRange
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.threeten.bp.ZoneOffset
Expand All @@ -22,37 +22,37 @@ class DayRangeTest {
@Test
fun `contains returns false if dateTime is before dayRange start`() {
val dateTime = ZonedDateTime.of(2019, 12, 26, 23, 59, 59, 0, ZoneOffset.UTC)
assertThat(dayRange.contains(dateTime)).isFalse
assertThat(dayRange.contains(dateTime)).isFalse()
}

@Test
fun `contains returns true if dateTime matches dayRange start`() {
val dateTime = ZonedDateTime.of(2019, 12, 27, 0, 0, 0, 0, ZoneOffset.UTC)
assertThat(dayRange.contains(dateTime)).isTrue
assertThat(dayRange.contains(dateTime)).isTrue()
}

@Test
fun `contains returns true if dateTime is after dayRange start`() {
val dateTime = ZonedDateTime.of(2019, 12, 27, 0, 0, 1, 0, ZoneOffset.UTC)
assertThat(dayRange.contains(dateTime)).isTrue
assertThat(dayRange.contains(dateTime)).isTrue()
}

@Test
fun `contains returns true if dateTime is before dayRange end`() {
val dateTime = ZonedDateTime.of(2019, 12, 30, 23, 59, 58, 0, ZoneOffset.UTC)
assertThat(dayRange.contains(dateTime)).isTrue
assertThat(dayRange.contains(dateTime)).isTrue()
}

@Test
fun `contains returns true if dateTime matches dayRange end`() {
val dateTime = ZonedDateTime.of(2019, 12, 30, 23, 59, 59, 0, ZoneOffset.UTC)
assertThat(dayRange.contains(dateTime)).isTrue
assertThat(dayRange.contains(dateTime)).isTrue()
}

@Test
fun `contains returns false if dateTime is after dayRange end`() {
val dateTime = ZonedDateTime.of(2019, 12, 31, 0, 0, 0, 0, ZoneOffset.UTC)
assertThat(dayRange.contains(dateTime)).isFalse
assertThat(dayRange.contains(dateTime)).isFalse()
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package nerd.tuxmobil.fahrplan.congress.models

import org.assertj.core.api.Assertions.assertThat
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test

class ScheduleDataTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nerd.tuxmobil.fahrplan.congress.models

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import info.metadude.android.eventfahrplan.commons.temporal.Moment.Companion.MILLISECONDS_OF_ONE_MINUTE
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

private typealias SessionModification = Session.() -> Unit
Expand Down Expand Up @@ -87,54 +87,54 @@ class SessionTest {
val session1 = createSession()
val session2 = Session(session1)
assertThat(session1).isEqualTo(session2)
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
}

@Test
fun `equals evaluates true for equal sessions`() {
val session1 = createSession()
val session2 = createSession()
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1).isEqualTo(session2)
}

@Test
fun `equals evaluates true for sessions with not considered fields modified`() {
val session1 = createSession()
val session2 = createSessionModifyingNonConsideredFields()
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1).isEqualTo(session2)
}

@Test
fun `equals evaluates false when comparing with null`() {
val session1 = createSession()
val session2 = null
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1).isNotEqualTo(session2)
}

@Test
fun `equals evaluates false when comparing with other type`() {
val session1 = createSession()
val session2 = "Other type"
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1).isNotEqualTo(session2)
}

@Test
fun `hashCode evaluates true for equal sessions`() {
val session1 = createSession()
val session2 = createSession()
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1.hashCode()).isEqualTo(session2.hashCode())
}

@Test
fun `hashCode evaluates true for sessions with not considered fields modified`() {
val session1 = createSession()
val session2 = createSessionModifyingNonConsideredFields()
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1.hashCode()).isEqualTo(session2.hashCode())
}

Expand Down Expand Up @@ -260,14 +260,14 @@ class SessionTest {
private fun assertOddSessionsAreNotEqual(session2Modification: SessionModification) {
val session1 = createSession()
val session2 = createSession().apply { session2Modification() }
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1).isNotEqualTo(session2)
}

private fun assertOddSessionsHaveOddHashCodes(session2Modification: SessionModification) {
val session1 = createSession()
val session2 = createSession().apply { session2Modification() }
assertThat(session1).isNotSameAs(session2)
assertThat(session1).isNotSameInstanceAs(session2)
assertThat(session1.hashCode()).isNotEqualTo(session2.hashCode())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package nerd.tuxmobil.fahrplan.congress.repositories

import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.ExperimentalCoroutinesApi
import nerd.tuxmobil.fahrplan.congress.TestExecutionContext
import nerd.tuxmobil.fahrplan.congress.exceptions.ExceptionHandling
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import kotlin.coroutines.CoroutineContext

Expand Down Expand Up @@ -35,7 +35,7 @@ class NetworkScopeTest {
networkScope.launchNamed("Test") {
throw Exception()
}
assertThat(isExceptionHandled).isTrue
assertThat(isExceptionHandled).isTrue()
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package nerd.tuxmobil.fahrplan.congress.schedule

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import nerd.tuxmobil.fahrplan.congress.NoLogging
import nerd.tuxmobil.fahrplan.congress.models.Session
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.fail
import org.junit.jupiter.api.Test

Expand Down Expand Up @@ -36,7 +36,7 @@ class NavigationMenuEntriesGeneratorTest {
sessions,
DAY_2_AT_830_AM,
)
assertThat(entries).isNotNull
assertThat(entries).isNotNull()
assertThat(entries.size).isEqualTo(3)
assertThat(entries[0]).isEqualTo("Day 1")
assertThat(entries[1]).isEqualTo("Day 2 - Today")
Expand All @@ -56,7 +56,7 @@ class NavigationMenuEntriesGeneratorTest {
sessions,
DAY_2_AT_830_AM,
)
assertThat(entries).isNotNull
assertThat(entries).isNotNull()
assertThat(entries.size).isEqualTo(3)
assertThat(entries[0]).isEqualTo("Day 1")
assertThat(entries[1]).isEqualTo("Day 2")
Expand All @@ -75,7 +75,7 @@ class NavigationMenuEntriesGeneratorTest {
sessions,
DAY_2_AT_830_AM,
)
assertThat(entries).isNotNull
assertThat(entries).isNotNull()
assertThat(entries.size).isEqualTo(3)
assertThat(entries[0]).isEqualTo("Day 1")
assertThat(entries[1]).isEqualTo("Day 2 - Today")
Expand All @@ -92,7 +92,7 @@ class NavigationMenuEntriesGeneratorTest {
sessions,
DAY_2_AT_830_AM,
)
assertThat(entries).isNotNull
assertThat(entries).isNotNull()
assertThat(entries.size).isEqualTo(1)
assertThat(entries.first()).isEqualTo("Day 1")
}
Expand All @@ -107,7 +107,7 @@ class NavigationMenuEntriesGeneratorTest {
sessions,
DAY_2_AT_810_AM,
)
assertThat(entries).isNotNull
assertThat(entries).isNotNull()
assertThat(entries.size).isEqualTo(1)
assertThat(entries.first()).isEqualTo("Day 1 - Today")
}
Expand All @@ -119,7 +119,7 @@ class NavigationMenuEntriesGeneratorTest {
emptyList(),
DAY_2_AT_830_AM,
)
assertThat(entries).isNotNull
assertThat(entries).isNotNull()
assertThat(entries.size).isEqualTo(0)
}

Expand All @@ -130,7 +130,7 @@ class NavigationMenuEntriesGeneratorTest {
emptyList(),
DAY_2_AT_830_AM,
)
assertThat(entries).isNotNull
assertThat(entries).isNotNull()
assertThat(entries.size).isEqualTo(0)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nerd.tuxmobil.fahrplan.congress.schedule

import com.google.common.truth.Truth.assertThat
import info.metadude.android.eventfahrplan.commons.temporal.Moment
import info.metadude.android.eventfahrplan.commons.temporal.Moment.Companion.MILLISECONDS_OF_ONE_MINUTE
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class TimeSegmentTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nerd.tuxmobil.fahrplan.congress.utils

import com.google.common.truth.Truth.assertThat
import nerd.tuxmobil.fahrplan.congress.extensions.WIKI_SESSION_TRACK_NAME
import nerd.tuxmobil.fahrplan.congress.models.Session
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class FeedbackUrlComposerTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nerd.tuxmobil.fahrplan.congress.utils

import com.google.common.truth.Truth.assertThat
import nerd.tuxmobil.fahrplan.congress.models.Session
import nerd.tuxmobil.fahrplan.congress.repositories.AppRepository
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class SessionUrlComposerTest {
Expand Down
Loading

0 comments on commit 8b680e0

Please sign in to comment.