package com.zb.mom.ww.mxgateway.client;

import static org.junit.jupiter.api.Assertions.assertEquals;

import mxaccess_gateway.v1.MxAccessGatewayGrpc;
import mxaccess_gateway.v1.MxaccessGateway.OpenSessionRequest;
import mxaccess_worker.v1.MxaccessWorker.WorkerEnvelope;
import org.junit.jupiter.api.Test;

final class GeneratedContractSmokeTests {
    @Test
    void generatedGatewayAndWorkerContractsCompile() {
        OpenSessionRequest request = OpenSessionRequest.newBuilder()
                .setClientSessionName("junit")
                .build();
        WorkerEnvelope envelope = WorkerEnvelope.newBuilder()
                .setProtocolVersion(MxGatewayClientVersion.workerProtocolVersion())
                .build();

        assertEquals("junit", request.getClientSessionName());
        assertEquals("mxaccess_gateway.v1.MxAccessGateway", MxAccessGatewayGrpc.SERVICE_NAME);
        assertEquals(1, envelope.getProtocolVersion());
    }

    @Test
    void javaSeventeenToolchainRunsTests() {
        // Pinned to 17: the client is retargeted to JDK 17 so it loads on
        // Ignition 8.3's JDK 17 runtime (roadmap G0). A 17 build still runs on 21+.
        assertEquals(17, Runtime.version().feature());
    }
}
