battery-device-bts/src/test/java/com/battery/device/bts/BtsXmlCodecTest.java
@@ -11,11 +11,9 @@
import java.util.Map;
import java.util.Set;
import org.junit.jupiter.api.Test;
import com.battery.device.model.ChannelIdentity;
import com.battery.device.model.DeviceWorkStatus;
import com.battery.device.model.HistoryPage;
import com.battery.device.model.HistoryAvailability;
import com.battery.device.model.RealtimeSnapshot;
import com.battery.device.api.model.ChannelIdentity;
import com.battery.device.api.model.DeviceWorkStatus;
import com.battery.device.api.model.RealtimeSnapshot;
class BtsXmlCodecTest
{
@@ -87,58 +85,8 @@
        assertEquals(DeviceWorkStatus.FINISHED, snapshot.workStatus());
    }
    @Test
    void parsesHistoryPageAndHongKongDeviceTime()
    {
        ChannelIdentity channel = new ChannelIdentity("lab-bts", 24, 1, 1, 1);
        String xml = "<bts><cmd>download_resp</cmd>"
                + "<download devtype=\"24\" devid=\"1\" subdevid=\"1\" chlid=\"1\" testid=\"42\"/>"
                + "<list count=\"1\">"
                + "<data seqid=\"7\" stepid=\"1\" cycleid=\"2\" steptype=\"cc\" testtime=\"1000\" "
                + "atime=\"2026-08-25 18.00.00\" volt=\"3.5\" curr=\"1.2\" cap=\"0.1\" eng=\"0.35\" T1=\"25\"/>"
                + "</list></bts>";
        HistoryPage page = codec.parseHistory(xml, channel, "42", 7);
        assertEquals("42", page.btsTestId());
        assertEquals(8, page.nextPosition());
        assertEquals(Instant.parse("2026-08-25T10:00:00Z"), page.samples().get(0).deviceTime());
    }
    @Test
    void rejectsHistoryResponseForDifferentChannelOrTest()
    {
        ChannelIdentity requested = new ChannelIdentity("lab-bts", 24, 1, 1, 1);
        String xml = "<bts><cmd>download_resp</cmd>"
                + "<download devtype=\"24\" devid=\"1\" subdevid=\"1\" chlid=\"2\" testid=\"99\"/>"
                + "<list count=\"0\"/></bts>";
        BtsProtocolException exception = assertThrows(BtsProtocolException.class,
                () -> codec.parseHistory(xml, requested, "42", 1));
        assertEquals(BtsProtocolException.Reason.IDENTITY_MISMATCH, exception.reason());
    }
    @Test
    void buildsAndParsesHistoryAvailabilityForMultipleChannels()
    {
        ChannelIdentity first = new ChannelIdentity("lab-bts", 22, 3, 2, 8);
        ChannelIdentity second = new ChannelIdentity("lab-bts", 22, 3, 1, 6);
        String request = codec.inquireHistoryRequest(Set.of(first, second));
        String response = "<bts><cmd>inquiredf_resp</cmd><list count=\"2\">"
                + "<chl devtype=\"22\" devid=\"3\" subdevid=\"2\" chlid=\"8\" testid=\"11\" count=\"10\">true</chl>"
                + "<chl devtype=\"22\" devid=\"3\" subdevid=\"1\" chlid=\"6\" testid=\"10\" count=\"11\">false</chl>"
                + "</list></bts>";
        List<HistoryAvailability> result = codec.parseHistoryAvailability(response);
        assertTrue(request.contains("<cmd>inquiredf</cmd>"));
        assertTrue(request.contains("devtype=\"22\" devid=\"3\" subdevid=\"2\" chlid=\"8\" testid=\"0\""));
        assertTrue(request.contains("devtype=\"22\" devid=\"3\" subdevid=\"1\" chlid=\"6\" testid=\"0\""));
        assertEquals(new HistoryAvailability(first, "11", 10, true), result.get(0));
        assertEquals(new HistoryAvailability(second, "10", 11, false), result.get(1));
    }
    @Test
    void rejectsIllegalNumericData()
@@ -181,18 +129,8 @@
                () -> codec.parseDeviceInfo("<bts><cmd>getdevinfo_resp</cmd></bts>"));
        BtsProtocolException realtime = assertThrows(BtsProtocolException.class,
                () -> codec.parseSnapshots("<bts><cmd>inquire_resp</cmd></bts>", Instant.EPOCH));
        BtsProtocolException availability = assertThrows(BtsProtocolException.class,
                () -> codec.parseHistoryAvailability("<bts><cmd>inquiredf_resp</cmd></bts>"));
        ChannelIdentity channel = new ChannelIdentity("lab-bts", 24, 1, 1, 1);
        BtsProtocolException history = assertThrows(BtsProtocolException.class,
                () -> codec.parseHistory("<bts><cmd>download_resp</cmd>"
                                + "<download devtype=\"24\" devid=\"1\" subdevid=\"1\" chlid=\"1\" testid=\"42\"/>"
                                + "</bts>", channel, "42", 1));
        assertEquals(BtsProtocolException.Reason.MISSING_FIELD, discovery.reason());
        assertEquals(BtsProtocolException.Reason.MISSING_FIELD, realtime.reason());
        assertEquals(BtsProtocolException.Reason.MISSING_FIELD, availability.reason());
        assertEquals(BtsProtocolException.Reason.MISSING_FIELD, history.reason());
    }
    @Test