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

public final class NetworkSecurityGroupResourceSettingsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        NetworkSecurityGroupResourceSettings model =
            BinaryData
                .fromString(
                    "{\"resourceType\":\"Microsoft.Network/networkSecurityGroups\",\"securityRules\":[{\"name\":\"i\",\"access\":\"kvceoveilovnotyf\",\"description\":\"cnjbkcnxdhbt\",\"destinationAddressPrefix\":\"phywpnvj\",\"destinationPortRange\":\"qnermclfplphoxu\",\"direction\":\"rpabg\",\"priority\":1582480909,\"protocol\":\"bjtazqugxywpmu\",\"sourceAddressPrefix\":\"fjz\",\"sourcePortRange\":\"qkqujidsu\"}],\"targetResourceName\":\"onobglaocqx\"}")
                .toObject(NetworkSecurityGroupResourceSettings.class);
        Assertions.assertEquals("onobglaocqx", model.targetResourceName());
        Assertions.assertEquals("i", model.securityRules().get(0).name());
        Assertions.assertEquals("kvceoveilovnotyf", model.securityRules().get(0).access());
        Assertions.assertEquals("cnjbkcnxdhbt", model.securityRules().get(0).description());
        Assertions.assertEquals("phywpnvj", model.securityRules().get(0).destinationAddressPrefix());
        Assertions.assertEquals("qnermclfplphoxu", model.securityRules().get(0).destinationPortRange());
        Assertions.assertEquals("rpabg", model.securityRules().get(0).direction());
        Assertions.assertEquals(1582480909, model.securityRules().get(0).priority());
        Assertions.assertEquals("bjtazqugxywpmu", model.securityRules().get(0).protocol());
        Assertions.assertEquals("fjz", model.securityRules().get(0).sourceAddressPrefix());
        Assertions.assertEquals("qkqujidsu", model.securityRules().get(0).sourcePortRange());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        NetworkSecurityGroupResourceSettings model =
            new NetworkSecurityGroupResourceSettings()
                .withTargetResourceName("onobglaocqx")
                .withSecurityRules(
                    Arrays
                        .asList(
                            new NsgSecurityRule()
                                .withName("i")
                                .withAccess("kvceoveilovnotyf")
                                .withDescription("cnjbkcnxdhbt")
                                .withDestinationAddressPrefix("phywpnvj")
                                .withDestinationPortRange("qnermclfplphoxu")
                                .withDirection("rpabg")
                                .withPriority(1582480909)
                                .withProtocol("bjtazqugxywpmu")
                                .withSourceAddressPrefix("fjz")
                                .withSourcePortRange("qkqujidsu")));
        model = BinaryData.fromObject(model).toObject(NetworkSecurityGroupResourceSettings.class);
        Assertions.assertEquals("onobglaocqx", model.targetResourceName());
        Assertions.assertEquals("i", model.securityRules().get(0).name());
        Assertions.assertEquals("kvceoveilovnotyf", model.securityRules().get(0).access());
        Assertions.assertEquals("cnjbkcnxdhbt", model.securityRules().get(0).description());
        Assertions.assertEquals("phywpnvj", model.securityRules().get(0).destinationAddressPrefix());
        Assertions.assertEquals("qnermclfplphoxu", model.securityRules().get(0).destinationPortRange());
        Assertions.assertEquals("rpabg", model.securityRules().get(0).direction());
        Assertions.assertEquals(1582480909, model.securityRules().get(0).priority());
        Assertions.assertEquals("bjtazqugxywpmu", model.securityRules().get(0).protocol());
        Assertions.assertEquals("fjz", model.securityRules().get(0).sourceAddressPrefix());
        Assertions.assertEquals("qkqujidsu", model.securityRules().get(0).sourcePortRange());
    }
}
