Skip to content

Commit

Permalink
Add test for routing parameters with current time
Browse files Browse the repository at this point in the history
Introduced a new integration test to verify the routing parameters service when provided with the current time. This ensures the service correctly handles real-time prompts and checks it against a near-current timestamp, allowing a margin of fewer than 10 seconds.
  • Loading branch information
ljhbt committed Sep 19, 2024
1 parent c380797 commit 879d56a
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import java.time.Duration
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter


Expand Down Expand Up @@ -48,4 +50,25 @@ class RoutingParametersServiceIntegrationTest {
.isNotNull
.hasSize(1)
}

@Test
fun getRoutingParametersWithNow() {
//given
assertThat(routingParametersService).isNotNull

//when
val prompt = "Wie komme ich jetzt vom Grüningweg zur Holmer Straße in Wedel?"
val routingParameters = routingParametersService?.getRoutingParameters(REQUEST_ID, prompt)

//then
val time = NOW
assertThat(routingParameters?.time).isNotNull()
val parsedTime = routingParameters?.time?.let { ZonedDateTime.parse(it) }
val between = Duration.between(time, parsedTime)
assertThat(between.seconds).isLessThan(10)

assertThat(conversationCache?.getConversation(REQUEST_ID))
.isNotNull
.hasSize(1)
}
}

0 comments on commit 879d56a

Please sign in to comment.