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

package com.azure.resourcemanager.batch.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.batch.models.DynamicVNetAssignmentScope;
import com.azure.resourcemanager.batch.models.InboundEndpointProtocol;
import com.azure.resourcemanager.batch.models.InboundNatPool;
import com.azure.resourcemanager.batch.models.IpAddressProvisioningType;
import com.azure.resourcemanager.batch.models.NetworkConfiguration;
import com.azure.resourcemanager.batch.models.PoolEndpointConfiguration;
import com.azure.resourcemanager.batch.models.PublicIpAddressConfiguration;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class NetworkConfigurationTests {
    @Test
    public void testDeserialize() {
        NetworkConfiguration model =
            BinaryData
                .fromString(
                    "{\"subnetId\":\"z\",\"dynamicVnetAssignmentScope\":\"job\",\"endpointConfiguration\":{\"inboundNatPools\":[{\"name\":\"vmkqzeqq\",\"protocol\":\"TCP\",\"backendPort\":52302074,\"frontendPortRangeStart\":750386751,\"frontendPortRangeEnd\":1896660287,\"networkSecurityGroupRules\":[]},{\"name\":\"xmhhvhgureo\",\"protocol\":\"UDP\",\"backendPort\":1245356368,\"frontendPortRangeStart\":1250108412,\"frontendPortRangeEnd\":1368192153,\"networkSecurityGroupRules\":[]},{\"name\":\"agxti\",\"protocol\":\"TCP\",\"backendPort\":897567613,\"frontendPortRangeStart\":1120938995,\"frontendPortRangeEnd\":2091557827,\"networkSecurityGroupRules\":[]}]},\"publicIPAddressConfiguration\":{\"provision\":\"NoPublicIPAddresses\",\"ipAddressIds\":[\"gqxndlkzgxhuripl\",\"podxunkb\",\"bxmubyynt\",\"lrb\"]}}")
                .toObject(NetworkConfiguration.class);
        Assertions.assertEquals("z", model.subnetId());
        Assertions.assertEquals(DynamicVNetAssignmentScope.JOB, model.dynamicVnetAssignmentScope());
        Assertions.assertEquals("vmkqzeqq", model.endpointConfiguration().inboundNatPools().get(0).name());
        Assertions
            .assertEquals(
                InboundEndpointProtocol.TCP, model.endpointConfiguration().inboundNatPools().get(0).protocol());
        Assertions.assertEquals(52302074, model.endpointConfiguration().inboundNatPools().get(0).backendPort());
        Assertions
            .assertEquals(750386751, model.endpointConfiguration().inboundNatPools().get(0).frontendPortRangeStart());
        Assertions
            .assertEquals(1896660287, model.endpointConfiguration().inboundNatPools().get(0).frontendPortRangeEnd());
        Assertions
            .assertEquals(
                IpAddressProvisioningType.NO_PUBLIC_IPADDRESSES, model.publicIpAddressConfiguration().provision());
        Assertions.assertEquals("gqxndlkzgxhuripl", model.publicIpAddressConfiguration().ipAddressIds().get(0));
    }

    @Test
    public void testSerialize() {
        NetworkConfiguration model =
            new NetworkConfiguration()
                .withSubnetId("z")
                .withDynamicVnetAssignmentScope(DynamicVNetAssignmentScope.JOB)
                .withEndpointConfiguration(
                    new PoolEndpointConfiguration()
                        .withInboundNatPools(
                            Arrays
                                .asList(
                                    new InboundNatPool()
                                        .withName("vmkqzeqq")
                                        .withProtocol(InboundEndpointProtocol.TCP)
                                        .withBackendPort(52302074)
                                        .withFrontendPortRangeStart(750386751)
                                        .withFrontendPortRangeEnd(1896660287)
                                        .withNetworkSecurityGroupRules(Arrays.asList()),
                                    new InboundNatPool()
                                        .withName("xmhhvhgureo")
                                        .withProtocol(InboundEndpointProtocol.UDP)
                                        .withBackendPort(1245356368)
                                        .withFrontendPortRangeStart(1250108412)
                                        .withFrontendPortRangeEnd(1368192153)
                                        .withNetworkSecurityGroupRules(Arrays.asList()),
                                    new InboundNatPool()
                                        .withName("agxti")
                                        .withProtocol(InboundEndpointProtocol.TCP)
                                        .withBackendPort(897567613)
                                        .withFrontendPortRangeStart(1120938995)
                                        .withFrontendPortRangeEnd(2091557827)
                                        .withNetworkSecurityGroupRules(Arrays.asList()))))
                .withPublicIpAddressConfiguration(
                    new PublicIpAddressConfiguration()
                        .withProvision(IpAddressProvisioningType.NO_PUBLIC_IPADDRESSES)
                        .withIpAddressIds(Arrays.asList("gqxndlkzgxhuripl", "podxunkb", "bxmubyynt", "lrb")));
        model = BinaryData.fromObject(model).toObject(NetworkConfiguration.class);
        Assertions.assertEquals("z", model.subnetId());
        Assertions.assertEquals(DynamicVNetAssignmentScope.JOB, model.dynamicVnetAssignmentScope());
        Assertions.assertEquals("vmkqzeqq", model.endpointConfiguration().inboundNatPools().get(0).name());
        Assertions
            .assertEquals(
                InboundEndpointProtocol.TCP, model.endpointConfiguration().inboundNatPools().get(0).protocol());
        Assertions.assertEquals(52302074, model.endpointConfiguration().inboundNatPools().get(0).backendPort());
        Assertions
            .assertEquals(750386751, model.endpointConfiguration().inboundNatPools().get(0).frontendPortRangeStart());
        Assertions
            .assertEquals(1896660287, model.endpointConfiguration().inboundNatPools().get(0).frontendPortRangeEnd());
        Assertions
            .assertEquals(
                IpAddressProvisioningType.NO_PUBLIC_IPADDRESSES, model.publicIpAddressConfiguration().provision());
        Assertions.assertEquals("gqxndlkzgxhuripl", model.publicIpAddressConfiguration().ipAddressIds().get(0));
    }
}
