package com.battery.device.neware;
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import org.junit.jupiter.api.Test;
|
import com.battery.device.api.StepDirectionResolver.Direction;
|
|
/** 工步类型数字到方向的映射:已知取值照映射,未确认取值保持未知,不按电流符号猜。 */
|
class NewareStepDirectionResolverTest
|
{
|
private final NewareStepDirectionResolver resolver = new NewareStepDirectionResolver();
|
|
@Test
|
void mapsTheConfirmedNumericStepTypes()
|
{
|
// 现场实测:1 充电、2 放电、4 搁置;空白按未知处理。
|
assertEquals(Direction.CHARGE, resolver.resolve("1"));
|
assertEquals(Direction.DISCHARGE, resolver.resolve("2"));
|
assertEquals(Direction.REST, resolver.resolve(" 4 "));
|
}
|
|
@Test
|
void keepsUnconfirmedNumericTypesUnknown()
|
{
|
// cap_step 里还出现过 3、5、7、13,语义未确认;未知就是未知,不能按数值或电流方向推断。
|
for (String type : new String[] { "3", "5", "7", "13", "0", "99", "abc", "cc", "rest", " " })
|
assertEquals(Direction.UNKNOWN, resolver.resolve(type), type);
|
assertEquals(Direction.UNKNOWN, resolver.resolve(null));
|
}
|
}
|