yeg
6 天以前 a04222c873e5e55f48c8d33b5c0bc46fa524ac8d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.battery.device.bts;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import com.battery.device.api.StepDirectionResolver.Direction;
import org.junit.jupiter.api.Test;
 
class BtsStepDirectionResolverTest
{
    @Test
    void identifiesOnlyProtocolDirectionsAndKeepsAmbiguousTypesUnknown()
    {
        var resolver = new BtsStepDirectionResolver();
        for (String type : List.of("cc", "cv", "cccv", "cp", "cr", " CHARGE "))
            assertEquals(Direction.CHARGE, resolver.resolve(type));
        for (String type : List.of("dc", "dp", "dr", "dv", "cccd", "DISCHARGE"))
            assertEquals(Direction.DISCHARGE, resolver.resolve(type));
        assertEquals(Direction.REST, resolver.resolve(" rest "));
        for (String type : List.of("pcccv", "pulse", "sim", "恒流充电", "0.1C", ""))
            assertEquals(Direction.UNKNOWN, resolver.resolve(type));
        assertEquals(Direction.UNKNOWN, resolver.resolve(null));
    }
}