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

package com.azure.resourcemanager.devtestlabs.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devtestlabs.models.InboundNatRule;
import com.azure.resourcemanager.devtestlabs.models.NetworkInterfaceProperties;
import com.azure.resourcemanager.devtestlabs.models.SharedPublicIpAddressConfiguration;
import com.azure.resourcemanager.devtestlabs.models.TransportProtocol;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class NetworkInterfacePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkInterfaceProperties model =
            BinaryData
                .fromString(
                    "{\"virtualNetworkId\":\"j\",\"subnetId\":\"ivfxzsjabibsyst\",\"publicIpAddressId\":\"fsdjpvkvp\",\"publicIpAddress\":\"xbkzbzkdvncj\",\"privateIpAddress\":\"udurgkakmokz\",\"dnsName\":\"jk\",\"rdpAuthority\":\"fhmouwq\",\"sshAuthority\":\"zrfze\",\"sharedPublicIpAddressConfiguration\":{\"inboundNatRules\":[{\"transportProtocol\":\"Tcp\",\"frontendPort\":707940784,\"backendPort\":2103532940},{\"transportProtocol\":\"Udp\",\"frontendPort\":1810814701,\"backendPort\":2014142159},{\"transportProtocol\":\"Tcp\",\"frontendPort\":377677013,\"backendPort\":684811222}]}}")
                .toObject(NetworkInterfaceProperties.class);
        Assertions.assertEquals("j", model.virtualNetworkId());
        Assertions.assertEquals("ivfxzsjabibsyst", model.subnetId());
        Assertions.assertEquals("fsdjpvkvp", model.publicIpAddressId());
        Assertions.assertEquals("xbkzbzkdvncj", model.publicIpAddress());
        Assertions.assertEquals("udurgkakmokz", model.privateIpAddress());
        Assertions.assertEquals("jk", model.dnsName());
        Assertions.assertEquals("fhmouwq", model.rdpAuthority());
        Assertions.assertEquals("zrfze", model.sshAuthority());
        Assertions
            .assertEquals(
                TransportProtocol.TCP,
                model.sharedPublicIpAddressConfiguration().inboundNatRules().get(0).transportProtocol());
        Assertions
            .assertEquals(
                707940784, model.sharedPublicIpAddressConfiguration().inboundNatRules().get(0).frontendPort());
        Assertions
            .assertEquals(
                2103532940, model.sharedPublicIpAddressConfiguration().inboundNatRules().get(0).backendPort());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkInterfaceProperties model =
            new NetworkInterfaceProperties()
                .withVirtualNetworkId("j")
                .withSubnetId("ivfxzsjabibsyst")
                .withPublicIpAddressId("fsdjpvkvp")
                .withPublicIpAddress("xbkzbzkdvncj")
                .withPrivateIpAddress("udurgkakmokz")
                .withDnsName("jk")
                .withRdpAuthority("fhmouwq")
                .withSshAuthority("zrfze")
                .withSharedPublicIpAddressConfiguration(
                    new SharedPublicIpAddressConfiguration()
                        .withInboundNatRules(
                            Arrays
                                .asList(
                                    new InboundNatRule()
                                        .withTransportProtocol(TransportProtocol.TCP)
                                        .withFrontendPort(707940784)
                                        .withBackendPort(2103532940),
                                    new InboundNatRule()
                                        .withTransportProtocol(TransportProtocol.UDP)
                                        .withFrontendPort(1810814701)
                                        .withBackendPort(2014142159),
                                    new InboundNatRule()
                                        .withTransportProtocol(TransportProtocol.TCP)
                                        .withFrontendPort(377677013)
                                        .withBackendPort(684811222))));
        model = BinaryData.fromObject(model).toObject(NetworkInterfaceProperties.class);
        Assertions.assertEquals("j", model.virtualNetworkId());
        Assertions.assertEquals("ivfxzsjabibsyst", model.subnetId());
        Assertions.assertEquals("fsdjpvkvp", model.publicIpAddressId());
        Assertions.assertEquals("xbkzbzkdvncj", model.publicIpAddress());
        Assertions.assertEquals("udurgkakmokz", model.privateIpAddress());
        Assertions.assertEquals("jk", model.dnsName());
        Assertions.assertEquals("fhmouwq", model.rdpAuthority());
        Assertions.assertEquals("zrfze", model.sshAuthority());
        Assertions
            .assertEquals(
                TransportProtocol.TCP,
                model.sharedPublicIpAddressConfiguration().inboundNatRules().get(0).transportProtocol());
        Assertions
            .assertEquals(
                707940784, model.sharedPublicIpAddressConfiguration().inboundNatRules().get(0).frontendPort());
        Assertions
            .assertEquals(
                2103532940, model.sharedPublicIpAddressConfiguration().inboundNatRules().get(0).backendPort());
    }
}
