// 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.JitNetworkAccessPortRule;
import com.azure.resourcemanager.security.models.Protocol;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class JitNetworkAccessPortRuleTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        JitNetworkAccessPortRule model =
            BinaryData
                .fromString(
                    "{\"number\":1664438715,\"protocol\":\"UDP\",\"allowedSourceAddressPrefix\":\"tnzoibgsxgnxfy\",\"allowedSourceAddressPrefixes\":[\"mpqoxw\",\"o\",\"dbxiqx\"],\"maxRequestAccessDuration\":\"iiqbi\"}")
                .toObject(JitNetworkAccessPortRule.class);
        Assertions.assertEquals(1664438715, model.number());
        Assertions.assertEquals(Protocol.UDP, model.protocol());
        Assertions.assertEquals("tnzoibgsxgnxfy", model.allowedSourceAddressPrefix());
        Assertions.assertEquals("mpqoxw", model.allowedSourceAddressPrefixes().get(0));
        Assertions.assertEquals("iiqbi", model.maxRequestAccessDuration());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        JitNetworkAccessPortRule model =
            new JitNetworkAccessPortRule()
                .withNumber(1664438715)
                .withProtocol(Protocol.UDP)
                .withAllowedSourceAddressPrefix("tnzoibgsxgnxfy")
                .withAllowedSourceAddressPrefixes(Arrays.asList("mpqoxw", "o", "dbxiqx"))
                .withMaxRequestAccessDuration("iiqbi");
        model = BinaryData.fromObject(model).toObject(JitNetworkAccessPortRule.class);
        Assertions.assertEquals(1664438715, model.number());
        Assertions.assertEquals(Protocol.UDP, model.protocol());
        Assertions.assertEquals("tnzoibgsxgnxfy", model.allowedSourceAddressPrefix());
        Assertions.assertEquals("mpqoxw", model.allowedSourceAddressPrefixes().get(0));
        Assertions.assertEquals("iiqbi", model.maxRequestAccessDuration());
    }
}
