#
Junjie
2 天以前 90402710d962aa357062ecb94649e0f277c1dfb3
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.utils.station.model;
 
import com.zy.core.utils.StationOperateProcessUtils;
import com.zy.core.utils.station.StationDispatchLoadSupport;
import com.zy.core.utils.station.StationOutboundDecisionSupport;
import com.zy.core.utils.station.StationRerouteProcessor;
import org.junit.jupiter.api.Test;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
 
class StationModelTypePlacementTest {
 
    @Test
    void rerouteTypes_areNoLongerNestedInsideStationOperateProcessUtils() {
        assertFalse(hasDeclaredClass(StationOperateProcessUtils.class, "RerouteSceneType"));
        assertFalse(hasDeclaredClass(StationOperateProcessUtils.class, "RerouteDecision"));
        assertFalse(hasDeclaredClass(StationOperateProcessUtils.class, "RerouteContext"));
        assertFalse(hasDeclaredClass(StationOperateProcessUtils.class, "RerouteCommandPlan"));
        assertFalse(hasDeclaredClass(StationOperateProcessUtils.class, "RerouteExecutionResult"));
    }
 
    @Test
    void dispatchLoadTypes_areNoLongerNestedInsideStationDispatchLoadSupport() {
        assertFalse(hasDeclaredClass(StationDispatchLoadSupport.class, "DispatchLimitConfig"));
        assertFalse(hasDeclaredClass(StationDispatchLoadSupport.class, "LoadGuardState"));
        assertFalse(hasDeclaredClass(StationDispatchLoadSupport.class, "LoopHitResult"));
    }
 
    @Test
    void outboundDecisionTypes_areNoLongerNestedInsideStationOutboundDecisionSupport() {
        assertFalse(hasDeclaredClass(StationOutboundDecisionSupport.class, "OutOrderDispatchDecision"));
        assertFalse(hasDeclaredClass(StationOutboundDecisionSupport.class, "CircleTargetCandidate"));
    }
 
    @Test
    void rerouteProcessor_isLocatedUnderStationPackage() {
        assertEquals("com.zy.core.utils.station", StationRerouteProcessor.class.getPackageName());
    }
 
    private static boolean hasDeclaredClass(Class<?> ownerType, String simpleName) {
        for (Class<?> declaredClass : ownerType.getDeclaredClasses()) {
            if (simpleName.equals(declaredClass.getSimpleName())) {
                return true;
            }
        }
        return false;
    }
}