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())));
|
}
|
}
|