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

package com.azure.resourcemanager.resourcemover.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.resourcemover.models.NsgReference;
import com.azure.resourcemanager.resourcemover.models.SubnetResourceSettings;
import com.azure.resourcemanager.resourcemover.models.VirtualNetworkResourceSettings;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class VirtualNetworkResourceSettingsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VirtualNetworkResourceSettings model =
            BinaryData
                .fromString(
                    "{\"resourceType\":\"Microsoft.Network/virtualNetworks\",\"enableDdosProtection\":true,\"addressSpace\":[\"ocipazyxoeg\",\"kgjn\",\"iucgygevqzn\",\"yp\"],\"dnsServers\":[\"p\",\"zcdrqjsdpydnfyhx\",\"eoejzic\",\"ifsjttgzfbishcb\"],\"subnets\":[{\"name\":\"deyeamdphagalpbu\",\"addressPrefix\":\"gipwhonowkg\",\"networkSecurityGroup\":{\"sourceArmResourceId\":\"wankixzbi\"}},{\"name\":\"eputtmrywnuzoqf\",\"addressPrefix\":\"yqzrnkcqvyxlw\",\"networkSecurityGroup\":{\"sourceArmResourceId\":\"lsicohoqqnwv\"}},{\"name\":\"yav\",\"addressPrefix\":\"heun\",\"networkSecurityGroup\":{\"sourceArmResourceId\":\"qhgyxzkonocukok\"}},{\"name\":\"axuconuq\",\"addressPrefix\":\"fkbey\",\"networkSecurityGroup\":{\"sourceArmResourceId\":\"wrmjmwvvjektc\"}}],\"targetResourceName\":\"senhwlrs\"}")
                .toObject(VirtualNetworkResourceSettings.class);
        Assertions.assertEquals("senhwlrs", model.targetResourceName());
        Assertions.assertEquals(true, model.enableDdosProtection());
        Assertions.assertEquals("ocipazyxoeg", model.addressSpace().get(0));
        Assertions.assertEquals("p", model.dnsServers().get(0));
        Assertions.assertEquals("deyeamdphagalpbu", model.subnets().get(0).name());
        Assertions.assertEquals("gipwhonowkg", model.subnets().get(0).addressPrefix());
        Assertions.assertEquals("wankixzbi", model.subnets().get(0).networkSecurityGroup().sourceArmResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VirtualNetworkResourceSettings model =
            new VirtualNetworkResourceSettings()
                .withTargetResourceName("senhwlrs")
                .withEnableDdosProtection(true)
                .withAddressSpace(Arrays.asList("ocipazyxoeg", "kgjn", "iucgygevqzn", "yp"))
                .withDnsServers(Arrays.asList("p", "zcdrqjsdpydnfyhx", "eoejzic", "ifsjttgzfbishcb"))
                .withSubnets(
                    Arrays
                        .asList(
                            new SubnetResourceSettings()
                                .withName("deyeamdphagalpbu")
                                .withAddressPrefix("gipwhonowkg")
                                .withNetworkSecurityGroup(new NsgReference().withSourceArmResourceId("wankixzbi")),
                            new SubnetResourceSettings()
                                .withName("eputtmrywnuzoqf")
                                .withAddressPrefix("yqzrnkcqvyxlw")
                                .withNetworkSecurityGroup(new NsgReference().withSourceArmResourceId("lsicohoqqnwv")),
                            new SubnetResourceSettings()
                                .withName("yav")
                                .withAddressPrefix("heun")
                                .withNetworkSecurityGroup(
                                    new NsgReference().withSourceArmResourceId("qhgyxzkonocukok")),
                            new SubnetResourceSettings()
                                .withName("axuconuq")
                                .withAddressPrefix("fkbey")
                                .withNetworkSecurityGroup(
                                    new NsgReference().withSourceArmResourceId("wrmjmwvvjektc"))));
        model = BinaryData.fromObject(model).toObject(VirtualNetworkResourceSettings.class);
        Assertions.assertEquals("senhwlrs", model.targetResourceName());
        Assertions.assertEquals(true, model.enableDdosProtection());
        Assertions.assertEquals("ocipazyxoeg", model.addressSpace().get(0));
        Assertions.assertEquals("p", model.dnsServers().get(0));
        Assertions.assertEquals("deyeamdphagalpbu", model.subnets().get(0).name());
        Assertions.assertEquals("gipwhonowkg", model.subnets().get(0).addressPrefix());
        Assertions.assertEquals("wankixzbi", model.subnets().get(0).networkSecurityGroup().sourceArmResourceId());
    }
}
