// 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.fluent.models.VirtualNetworkProperties;
import com.azure.resourcemanager.devtestlabs.models.Subnet;
import com.azure.resourcemanager.devtestlabs.models.SubnetOverride;
import com.azure.resourcemanager.devtestlabs.models.SubnetSharedPublicIpAddressConfiguration;
import com.azure.resourcemanager.devtestlabs.models.UsagePermissionType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class VirtualNetworkPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VirtualNetworkProperties model =
            BinaryData
                .fromString(
                    "{\"allowedSubnets\":[{\"resourceId\":\"hjm\",\"labSubnetName\":\"nbsoqeqalarv\",\"allowPublicIp\":\"Deny\"},{\"resourceId\":\"nbtgfebwl\",\"labSubnetName\":\"mhyreeudz\",\"allowPublicIp\":\"Default\"},{\"resourceId\":\"pdqmjxlyyzglgouw\",\"labSubnetName\":\"mjjyuojq\",\"allowPublicIp\":\"Default\"},{\"resourceId\":\"xkjeytunlbfj\",\"labSubnetName\":\"rusnk\",\"allowPublicIp\":\"Allow\"}],\"description\":\"y\",\"externalProviderResourceId\":\"unjqh\",\"externalSubnets\":[{\"id\":\"aulk\",\"name\":\"kdk\"},{\"id\":\"mjnnawtq\",\"name\":\"pxuckpggq\"}],\"subnetOverrides\":[{\"resourceId\":\"ird\",\"labSubnetName\":\"isngwflqqmpizru\",\"useInVmCreationPermission\":\"Allow\",\"usePublicIpAddressPermission\":\"Allow\",\"sharedPublicIpAddressConfiguration\":{\"allowedPorts\":[]},\"virtualNetworkPoolName\":\"wfcngjsaas\"},{\"resourceId\":\"xtmkzjvkviir\",\"labSubnetName\":\"fgrwsdpgratzvz\",\"useInVmCreationPermission\":\"Deny\",\"usePublicIpAddressPermission\":\"Deny\",\"sharedPublicIpAddressConfiguration\":{\"allowedPorts\":[]},\"virtualNetworkPoolName\":\"tctbrxkjzwrgxffm\"},{\"resourceId\":\"kwfbkgo\",\"labSubnetName\":\"wopdbydpiz\",\"useInVmCreationPermission\":\"Allow\",\"usePublicIpAddressPermission\":\"Default\",\"sharedPublicIpAddressConfiguration\":{\"allowedPorts\":[]},\"virtualNetworkPoolName\":\"biygnugjknfsmfct\"}],\"createdDate\":\"2021-07-24T11:33:54Z\",\"provisioningState\":\"uyilflqoiquvrehm\",\"uniqueIdentifier\":\"jhvsujztczyt\"}")
                .toObject(VirtualNetworkProperties.class);
        Assertions.assertEquals("hjm", model.allowedSubnets().get(0).resourceId());
        Assertions.assertEquals("nbsoqeqalarv", model.allowedSubnets().get(0).labSubnetName());
        Assertions.assertEquals(UsagePermissionType.DENY, model.allowedSubnets().get(0).allowPublicIp());
        Assertions.assertEquals("y", model.description());
        Assertions.assertEquals("unjqh", model.externalProviderResourceId());
        Assertions.assertEquals("ird", model.subnetOverrides().get(0).resourceId());
        Assertions.assertEquals("isngwflqqmpizru", model.subnetOverrides().get(0).labSubnetName());
        Assertions.assertEquals(UsagePermissionType.ALLOW, model.subnetOverrides().get(0).useInVmCreationPermission());
        Assertions
            .assertEquals(UsagePermissionType.ALLOW, model.subnetOverrides().get(0).usePublicIpAddressPermission());
        Assertions.assertEquals("wfcngjsaas", model.subnetOverrides().get(0).virtualNetworkPoolName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VirtualNetworkProperties model =
            new VirtualNetworkProperties()
                .withAllowedSubnets(
                    Arrays
                        .asList(
                            new Subnet()
                                .withResourceId("hjm")
                                .withLabSubnetName("nbsoqeqalarv")
                                .withAllowPublicIp(UsagePermissionType.DENY),
                            new Subnet()
                                .withResourceId("nbtgfebwl")
                                .withLabSubnetName("mhyreeudz")
                                .withAllowPublicIp(UsagePermissionType.DEFAULT),
                            new Subnet()
                                .withResourceId("pdqmjxlyyzglgouw")
                                .withLabSubnetName("mjjyuojq")
                                .withAllowPublicIp(UsagePermissionType.DEFAULT),
                            new Subnet()
                                .withResourceId("xkjeytunlbfj")
                                .withLabSubnetName("rusnk")
                                .withAllowPublicIp(UsagePermissionType.ALLOW)))
                .withDescription("y")
                .withExternalProviderResourceId("unjqh")
                .withSubnetOverrides(
                    Arrays
                        .asList(
                            new SubnetOverride()
                                .withResourceId("ird")
                                .withLabSubnetName("isngwflqqmpizru")
                                .withUseInVmCreationPermission(UsagePermissionType.ALLOW)
                                .withUsePublicIpAddressPermission(UsagePermissionType.ALLOW)
                                .withSharedPublicIpAddressConfiguration(
                                    new SubnetSharedPublicIpAddressConfiguration().withAllowedPorts(Arrays.asList()))
                                .withVirtualNetworkPoolName("wfcngjsaas"),
                            new SubnetOverride()
                                .withResourceId("xtmkzjvkviir")
                                .withLabSubnetName("fgrwsdpgratzvz")
                                .withUseInVmCreationPermission(UsagePermissionType.DENY)
                                .withUsePublicIpAddressPermission(UsagePermissionType.DENY)
                                .withSharedPublicIpAddressConfiguration(
                                    new SubnetSharedPublicIpAddressConfiguration().withAllowedPorts(Arrays.asList()))
                                .withVirtualNetworkPoolName("tctbrxkjzwrgxffm"),
                            new SubnetOverride()
                                .withResourceId("kwfbkgo")
                                .withLabSubnetName("wopdbydpiz")
                                .withUseInVmCreationPermission(UsagePermissionType.ALLOW)
                                .withUsePublicIpAddressPermission(UsagePermissionType.DEFAULT)
                                .withSharedPublicIpAddressConfiguration(
                                    new SubnetSharedPublicIpAddressConfiguration().withAllowedPorts(Arrays.asList()))
                                .withVirtualNetworkPoolName("biygnugjknfsmfct")));
        model = BinaryData.fromObject(model).toObject(VirtualNetworkProperties.class);
        Assertions.assertEquals("hjm", model.allowedSubnets().get(0).resourceId());
        Assertions.assertEquals("nbsoqeqalarv", model.allowedSubnets().get(0).labSubnetName());
        Assertions.assertEquals(UsagePermissionType.DENY, model.allowedSubnets().get(0).allowPublicIp());
        Assertions.assertEquals("y", model.description());
        Assertions.assertEquals("unjqh", model.externalProviderResourceId());
        Assertions.assertEquals("ird", model.subnetOverrides().get(0).resourceId());
        Assertions.assertEquals("isngwflqqmpizru", model.subnetOverrides().get(0).labSubnetName());
        Assertions.assertEquals(UsagePermissionType.ALLOW, model.subnetOverrides().get(0).useInVmCreationPermission());
        Assertions
            .assertEquals(UsagePermissionType.ALLOW, model.subnetOverrides().get(0).usePublicIpAddressPermission());
        Assertions.assertEquals("wfcngjsaas", model.subnetOverrides().get(0).virtualNetworkPoolName());
    }
}
