Merge pull request #4 from rillig/fix-date-comparison-in-tests

Fix date comparison in JpaCityServiceTest
This commit is contained in:
Reinhard Prechtl 2017-12-30 23:21:21 +01:00 committed by GitHub
commit 0b8d94c670
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,6 +94,8 @@ internal class JpaCityServiceTest {
fun `'updateCity' should update existing values`() {
val existingCity = repository.save(CityEntity("city", "cityname", "description", Coordinate(1.0, -1.0))).toDto()
Thread.sleep(1)
val result = service.updateCity(existingCity.id, UpdateCityDto("new name", "new description", CoordinateDto(-1.0, -1.0)))
softly.assertThat(result).isNotNull
@ -102,7 +104,6 @@ internal class JpaCityServiceTest {
softly.assertThat(result?.description).isEqualTo("new description")
softly.assertThat(result?.location).isEqualTo(CoordinateDto(-1.0, -1.0))
softly.assertThat(result?.updatedAt).isAfter(existingCity.updatedAt)
softly.assertThat(result?.updatedAt).isAfter(existingCity.updatedAt)
softly.assertThat(result?.createdAt).isEqualTo(existingCity.createdAt)
}
@ -115,6 +116,8 @@ internal class JpaCityServiceTest {
location = Coordinate(1.0, -1.0),
updatedAt = LocalDateTime.now().minusYears(1))).toDto()
Thread.sleep(1)
val result = service.updateCity(existingCity.id, UpdateCityDto(null, null, null))
softly.assertThat(result).isNotNull
@ -125,4 +128,4 @@ internal class JpaCityServiceTest {
softly.assertThat(result?.updatedAt).isAfter(existingCity.updatedAt)
softly.assertThat(result?.createdAt).isEqualTo(existingCity.createdAt)
}
}
}