Skip to content
This repository was archived by the owner on Mar 30, 2025. It is now read-only.

Commit a428963

Browse files
committed
fix coordinates and title
1 parent 64f4965 commit a428963

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

adapter/src/main/kotlin/org/railwaystations/rsapi/adapter/db/InboxAdapter.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.railwaystations.rsapi.core.model.Coordinates
1515
import org.railwaystations.rsapi.core.model.InboxEntry
1616
import org.railwaystations.rsapi.core.model.ProblemReportType
1717
import org.railwaystations.rsapi.core.model.PublicInboxEntry
18+
import org.railwaystations.rsapi.core.model.ZERO
1819
import org.railwaystations.rsapi.core.ports.outbound.InboxPort
1920
import org.springframework.stereotype.Component
2021
import org.springframework.transaction.annotation.Transactional
@@ -82,9 +83,7 @@ class InboxAdapter(private val dsl: DSLContext) : InboxPort {
8283
)
8384

8485
private fun createCoordinates(lat: Double?, lon: Double?): Coordinates? {
85-
if (lat == null || lon == null) return null
86-
87-
return Coordinates(lat, lon)
86+
return Coordinates(lat ?: ZERO, lon ?: ZERO)
8887
}
8988

9089
override fun findPendingInboxEntries() =
@@ -124,7 +123,7 @@ class InboxAdapter(private val dsl: DSLContext) : InboxPort {
124123
coordinates = if (stationLat != null && stationLon != null) Coordinates(
125124
stationLat,
126125
stationLon
127-
) else Coordinates(lat ?: 0.0, lon ?: 0.0)
126+
) else Coordinates(lat ?: ZERO, lon ?: ZERO)
128127
)
129128

130129
@Transactional

adapter/src/test/kotlin/org/railwaystations/rsapi/adapter/db/InboxAdapterTest.kt

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,48 @@ class InboxAdapterTest : AbstractPostgreSqlTest() {
4242
coordinates = stationDe8000.coordinates,
4343
photographerNickname = user10.name,
4444
photographerEmail = user10.email,
45+
newCoordinates = Coordinates(),
4546
)
4647
)
4748
}
4849

4950
@Test
5051
fun findPendingInboxEntries() {
51-
val idPending = sut.insert(photoUploadDe8000.copy(done = false))
52+
val idPending1 = sut.insert(photoUploadDe8000.copy(done = false))
5253
sut.insert(photoUploadDe8000.copy(done = true))
54+
val idPending2 = sut.insert(problemReportDe8000.copy(done = false))
55+
val idPending3 = sut.insert(photoUploadMissingStation.copy(done = false))
5356

5457
val pendingEntries = sut.findPendingInboxEntries()
5558

56-
assertThat(pendingEntries.map { it.id }).containsExactly(idPending)
59+
assertThat(pendingEntries).containsExactlyInAnyOrder(
60+
photoUploadDe8000.copy(
61+
id = idPending1,
62+
title = "Offenburg Kreisschulzentrum",
63+
coordinates = Coordinates(lat = 48.459376429721, lon = 7.95547485351562),
64+
newCoordinates = Coordinates(),
65+
photographerNickname = "@user10",
66+
photographerEmail = "user10@example.com",
67+
),
68+
problemReportDe8000.copy(
69+
id = idPending2,
70+
title = "Offenburg Kreisschulzentrum",
71+
coordinates = Coordinates(lat = 48.459376429721, lon = 7.95547485351562),
72+
newCoordinates = Coordinates(),
73+
photographerNickname = "@user10",
74+
photographerEmail = "user10@example.com",
75+
existingPhotoUrlPath = null, // not in test db
76+
),
77+
photoUploadMissingStation.copy(
78+
id = idPending3,
79+
photographerNickname = "@user10",
80+
photographerEmail = "user10@example.com",
81+
title = null,
82+
newTitle = photoUploadMissingStation.title,
83+
coordinates = Coordinates(),
84+
newCoordinates = photoUploadMissingStation.coordinates,
85+
),
86+
)
5787
}
5888

5989
@Test

core/src/testFixtures/kotlin/org/railwaystations/rsapi/core/model/InboxEntryTestFixtures.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object InboxEntryTestFixtures {
2525
photographerId = user10.id,
2626
existingPhotoUrlPath = "de/4711.jpg",
2727
photoId = 4711,
28-
createdAt = now(),
28+
createdAt = now().truncatedTo(ChronoUnit.SECONDS),
2929
comment = "Photo outdated",
3030
problemReportType = ProblemReportType.PHOTO_OUTDATED,
3131
)
@@ -59,7 +59,7 @@ object InboxEntryTestFixtures {
5959
photographerNickname = user.name,
6060
extension = "jpg",
6161
rejectReason = rejectReason,
62-
createdAt = now(),
62+
createdAt = now().truncatedTo(ChronoUnit.SECONDS),
6363
done = done,
6464
)
6565
}

0 commit comments

Comments
 (0)