Skip to content

Commit 63082e4

Browse files
CopilotbedaHovorka
andauthored
test: revert unrelated TrainPathInteractionTest changes
Agent-Logs-Url: https://github.com/bedaHovorka/interlockSim/sessions/7e2018b6-a99c-4481-88ed-b1a527375dc3 Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
1 parent 7142fa0 commit 63082e4

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

core/src/jvmTest/kotlin/cz/vutbr/fit/interlockSim/sim/TrainPathInteractionTest.kt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import assertk.assertions.isNotNull
1616
import cz.vutbr.fit.interlockSim.objects.cells.DynamicInOut
1717
import cz.vutbr.fit.interlockSim.testutil.KoinTestBase
1818
import cz.vutbr.fit.interlockSim.testutil.MockSimulationContext
19+
import cz.vutbr.fit.interlockSim.testutil.createMockBlockedTrack
1920
import cz.vutbr.fit.interlockSim.testutil.createMockPath
21+
import cz.vutbr.fit.interlockSim.testutil.createMockSemaphoreMock
2022
import cz.vutbr.fit.interlockSim.testutil.createMockSimulationContext
2123
import cz.vutbr.fit.interlockSim.testutil.createMockTrack
2224
import cz.vutbr.fit.interlockSim.testutil.withMessage
@@ -90,14 +92,22 @@ class TrainPathInteractionTest : KoinTestBase() {
9092

9193
@Test
9294
fun `train requests path reservation ahead`() {
95+
// Arrange: Create a path representing the route ahead
96+
val track1 = createMockTrack("TRACK1", 100.0)
97+
val track2 = createMockTrack("TRACK2", 100.0)
98+
val pathAhead = createMockPath(track1, track2)
99+
93100
val mockOutOut = mockk<DynamicInOut>(relaxed = true)
94101
every { mockOutOut.name } returns "EXIT"
95102

96103
val timetable = Timetable(mockInOut, mockOutOut, Time(0.0), Time(0.0), 50.0)
97104
val train = Train(mockContext, timetable)
98105

106+
// Act: Train exists and can theoretically request path reservation
107+
val trainExists = train != null
108+
99109
// Assert: Train instance is valid for path operations
100-
assertThat(train).isNotNull()
110+
assertThat(trainExists).isEqualTo(true)
101111
}
102112

103113
@Test
@@ -126,6 +136,10 @@ class TrainPathInteractionTest : KoinTestBase() {
126136

127137
@Test
128138
fun `train handles path not available - waits`() {
139+
// Arrange: Create a blocked path scenario
140+
val blockedTrack = createMockBlockedTrack("BLOCKED_TRACK", 100.0)
141+
val pathBlocked = createMockPath(blockedTrack)
142+
129143
val mockOutOut = mockk<DynamicInOut>(relaxed = true)
130144
every { mockOutOut.name } returns "EXIT"
131145

@@ -138,6 +152,11 @@ class TrainPathInteractionTest : KoinTestBase() {
138152

139153
@Test
140154
fun `train handles path becoming available - proceeds`() {
155+
// Arrange: Create a path that initially blocks but becomes free
156+
val semaphore = createMockSemaphoreMock(true) // Initially allowing
157+
val track = createMockTrack("TRACK", 100.0)
158+
val pathUnblocked = createMockPath(track)
159+
141160
val mockOutOut = mockk<DynamicInOut>(relaxed = true)
142161
every { mockOutOut.name } returns "EXIT"
143162

0 commit comments

Comments
 (0)