#
Junjie
昨天 058d7bbb714634e42bff1dd71fdfca3a378421d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.zy.core.thread.impl.station;
 
import com.zy.core.enums.StationCommandType;
import com.zy.core.model.command.StationCommand;
import org.junit.jupiter.api.Test;
 
import java.util.List;
import java.util.stream.Collectors;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
 
class StationSegmentPlannerTest {
 
    @Test
    void buildPlan_usesLaterLiftTransferOccurrencesWhenLoopPathRevisitsStations() {
        StationSegmentPlanner planner = new StationSegmentPlanner();
 
        StationCommand original = new StationCommand();
        original.setTaskNo(11017);
        original.setCommandType(StationCommandType.MOVE);
        original.setStationId(121);
        original.setTargetStaNo(127);
        original.setNavigatePath(List.of(121, 124, 186, 189, 121, 124, 125, 127));
        original.setLiftTransferPath(List.of(121, 124, 186, 189, 121, 124, 127));
 
        StationSegmentExecutionPlan plan = planner.buildPlan(original);
 
        assertEquals(
                List.of(
                        List.of(121, 124),
                        List.of(124, 186),
                        List.of(186, 189),
                        List.of(189, 121),
                        List.of(121, 124),
                        List.of(124, 125, 127)
                ),
                plan.getSegmentCommands().stream()
                        .map(StationCommand::getNavigatePath)
                        .collect(Collectors.toList())
        );
        assertEquals(List.of(1, 2, 3, 4, 5, 6),
                plan.getSegmentCommands().stream()
                        .map(StationCommand::getSegmentNo)
                        .collect(Collectors.toList()));
        assertTrue(plan.getSegmentCommands().stream()
                .allMatch(command -> Integer.valueOf(6).equals(command.getSegmentCount())));
    }
}