yeg
2026-09-05 92f32acd847ea1700590bc669750f23ef499840e
battery-device-simulator/src/test/java/com/battery/device/simulator/SimulatorObservationAdapterContractTest.java
@@ -1,13 +1,38 @@
package com.battery.device.simulator;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import com.battery.device.model.ChannelIdentity;
import com.battery.device.model.DeviceConnectionStatus;
import com.battery.device.model.DeviceWorkStatus;
import com.battery.device.api.model.ChannelIdentity;
import com.battery.device.api.model.DeviceConnectionStatus;
import com.battery.device.api.model.DeviceWorkStatus;
class SimulatorObservationAdapterContractTest
{
    @Test void persistenceRejectsForeignIdentitiesAndOfflineCachedFacts() throws Exception
    {
        try (BtsDevelopmentSimulator simulator = new BtsDevelopmentSimulator(0))
        {
            ChannelIdentity channel = simulator.discoverChannels().get(0).identity();
            simulator.updateChannel(channel.devid(), channel.chlid(), true, DeviceWorkStatus.WORKING);
            simulator.advanceBts(java.time.Instant.now());
            assertNotNull(simulator.latestCabinet(channel));
            for (ChannelIdentity foreign : java.util.List.of(
                    new ChannelIdentity("another-adapter", channel.devtype(), channel.devid(), channel.subdevid(), channel.chlid()),
                    new ChannelIdentity(channel.adapterCode(), 999, channel.devid(), channel.subdevid(), channel.chlid()),
                    new ChannelIdentity(channel.adapterCode(), channel.devtype(), channel.devid(), 999, channel.chlid())))
            {
                assertNull(simulator.latestCabinet(foreign));
                assertNull(simulator.testPlan(foreign));
                assertTrue(simulator.stepRecords(foreign).isEmpty());
                assertTrue(simulator.cycleRecords(foreign).isEmpty());
            }
            simulator.updateChannel(channel.devid(), channel.chlid(), false, DeviceWorkStatus.WORKING);
            assertNull(simulator.latestCabinet(channel));
            assertTrue(simulator.stepRecords(channel).isEmpty());
            assertTrue(simulator.cycleRecords(channel).isEmpty());
        }
    }
    @Test
    void simulatorCanBeUsedDirectlyThroughTheVendorNeutralContract() throws Exception
    {