// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.security.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.security.models.JitNetworkAccessPolicyInitiatePort;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class JitNetworkAccessPolicyInitiatePortTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        JitNetworkAccessPolicyInitiatePort model =
            BinaryData
                .fromString(
                    "{\"number\":30912450,\"allowedSourceAddressPrefix\":\"wwp\",\"endTimeUtc\":\"2021-06-18T17:27:40Z\"}")
                .toObject(JitNetworkAccessPolicyInitiatePort.class);
        Assertions.assertEquals(30912450, model.number());
        Assertions.assertEquals("wwp", model.allowedSourceAddressPrefix());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-18T17:27:40Z"), model.endTimeUtc());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        JitNetworkAccessPolicyInitiatePort model =
            new JitNetworkAccessPolicyInitiatePort()
                .withNumber(30912450)
                .withAllowedSourceAddressPrefix("wwp")
                .withEndTimeUtc(OffsetDateTime.parse("2021-06-18T17:27:40Z"));
        model = BinaryData.fromObject(model).toObject(JitNetworkAccessPolicyInitiatePort.class);
        Assertions.assertEquals(30912450, model.number());
        Assertions.assertEquals("wwp", model.allowedSourceAddressPrefix());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-18T17:27:40Z"), model.endTimeUtc());
    }
}
