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

package com.azure.resourcemanager.elasticsan.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.elasticsan.fluent.models.VolumeGroupUpdateProperties;
import com.azure.resourcemanager.elasticsan.models.Action;
import com.azure.resourcemanager.elasticsan.models.EncryptionType;
import com.azure.resourcemanager.elasticsan.models.NetworkRuleSet;
import com.azure.resourcemanager.elasticsan.models.StorageTargetType;
import com.azure.resourcemanager.elasticsan.models.VirtualNetworkRule;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class VolumeGroupUpdatePropertiesTests {
    @Test
    public void testDeserialize() {
        VolumeGroupUpdateProperties model =
            BinaryData
                .fromString(
                    "{\"protocolType\":\"None\",\"encryption\":\"EncryptionAtRestWithPlatformKey\",\"networkAcls\":{\"virtualNetworkRules\":[{\"id\":\"vvtpgvdfgio\",\"action\":\"Allow\",\"state\":\"failed\"},{\"id\":\"tqxln\",\"action\":\"Allow\",\"state\":\"deprovisioning\"},{\"id\":\"gug\",\"action\":\"Allow\",\"state\":\"provisioning\"}]}}")
                .toObject(VolumeGroupUpdateProperties.class);
        Assertions.assertEquals(StorageTargetType.NONE, model.protocolType());
        Assertions.assertEquals(EncryptionType.ENCRYPTION_AT_REST_WITH_PLATFORM_KEY, model.encryption());
        Assertions
            .assertEquals("vvtpgvdfgio", model.networkAcls().virtualNetworkRules().get(0).virtualNetworkResourceId());
        Assertions.assertEquals(Action.ALLOW, model.networkAcls().virtualNetworkRules().get(0).action());
    }

    @Test
    public void testSerialize() {
        VolumeGroupUpdateProperties model =
            new VolumeGroupUpdateProperties()
                .withProtocolType(StorageTargetType.NONE)
                .withEncryption(EncryptionType.ENCRYPTION_AT_REST_WITH_PLATFORM_KEY)
                .withNetworkAcls(
                    new NetworkRuleSet()
                        .withVirtualNetworkRules(
                            Arrays
                                .asList(
                                    new VirtualNetworkRule()
                                        .withVirtualNetworkResourceId("vvtpgvdfgio")
                                        .withAction(Action.ALLOW),
                                    new VirtualNetworkRule()
                                        .withVirtualNetworkResourceId("tqxln")
                                        .withAction(Action.ALLOW),
                                    new VirtualNetworkRule()
                                        .withVirtualNetworkResourceId("gug")
                                        .withAction(Action.ALLOW))));
        model = BinaryData.fromObject(model).toObject(VolumeGroupUpdateProperties.class);
        Assertions.assertEquals(StorageTargetType.NONE, model.protocolType());
        Assertions.assertEquals(EncryptionType.ENCRYPTION_AT_REST_WITH_PLATFORM_KEY, model.encryption());
        Assertions
            .assertEquals("vvtpgvdfgio", model.networkAcls().virtualNetworkRules().get(0).virtualNetworkResourceId());
        Assertions.assertEquals(Action.ALLOW, model.networkAcls().virtualNetworkRules().get(0).action());
    }
}
