// 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.CachingType;
import com.azure.resourcemanager.batch.models.CloudServiceConfiguration;
import com.azure.resourcemanager.batch.models.ContainerConfiguration;
import com.azure.resourcemanager.batch.models.DataDisk;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.DiskEncryptionConfiguration;
import com.azure.resourcemanager.batch.models.DiskEncryptionTarget;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.NodePlacementConfiguration;
import com.azure.resourcemanager.batch.models.NodePlacementPolicyType;
import com.azure.resourcemanager.batch.models.OSDisk;
import com.azure.resourcemanager.batch.models.StorageAccountType;
import com.azure.resourcemanager.batch.models.VMExtension;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import com.azure.resourcemanager.batch.models.WindowsConfiguration;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class DeploymentConfigurationTests {
    @Test
    public void testDeserialize() {
        DeploymentConfiguration model =
            BinaryData
                .fromString(
                    "{\"cloudServiceConfiguration\":{\"osFamily\":\"lupj\",\"osVersion\":\"hfxobbcswsrtj\"},\"virtualMachineConfiguration\":{\"imageReference\":{\"publisher\":\"lrbpbewtghfgbl\",\"offer\":\"wxzvlvqhjkb\",\"sku\":\"ibtnmxiebwwaloay\",\"version\":\"gwrtzju\",\"id\":\"wyzmhtxon\"},\"nodeAgentSkuId\":\"mtsavjcbpwxqp\",\"windowsConfiguration\":{\"enableAutomaticUpdates\":true},\"dataDisks\":[{\"lun\":810124654,\"caching\":\"None\",\"diskSizeGB\":1935483255,\"storageAccountType\":\"Premium_LRS\"},{\"lun\":2067966148,\"caching\":\"ReadWrite\",\"diskSizeGB\":499230067,\"storageAccountType\":\"Premium_LRS\"},{\"lun\":1448281883,\"caching\":\"ReadOnly\",\"diskSizeGB\":1468047146,\"storageAccountType\":\"Premium_LRS\"}],\"licenseType\":\"riwwroy\",\"containerConfiguration\":{\"containerImageNames\":[\"rmcqiby\",\"nojvknmefqsg\",\"vah\",\"pjyzhpv\"],\"containerRegistries\":[]},\"diskEncryptionConfiguration\":{\"targets\":[\"TemporaryDisk\",\"TemporaryDisk\",\"OsDisk\"]},\"nodePlacementConfiguration\":{\"policy\":\"Zonal\"},\"extensions\":[{\"name\":\"lxkvu\",\"publisher\":\"fhzovawjvzunluth\",\"type\":\"n\",\"typeHandlerVersion\":\"nxipeil\",\"autoUpgradeMinorVersion\":false,\"settings\":\"dataaejxd\",\"protectedSettings\":\"datatskzbbtdzumveek\",\"provisionAfterExtensions\":[]},{\"name\":\"wozuhkf\",\"publisher\":\"bsjyofdx\",\"type\":\"uusdttouwa\",\"typeHandlerVersion\":\"ekqvkeln\",\"autoUpgradeMinorVersion\":true,\"settings\":\"dataxwyjsflhhc\",\"protectedSettings\":\"datalnjixisxya\",\"provisionAfterExtensions\":[]},{\"name\":\"oyaqcslyjpkiid\",\"publisher\":\"yexz\",\"type\":\"eli\",\"typeHandlerVersion\":\"nr\",\"autoUpgradeMinorVersion\":true,\"settings\":\"datalhbnxkna\",\"protectedSettings\":\"dataulppggdtpnapnyir\",\"provisionAfterExtensions\":[]},{\"name\":\"uhpigvp\",\"publisher\":\"ylgqgitxmedjvcsl\",\"type\":\"n\",\"typeHandlerVersion\":\"wncwzzhxgktrmg\",\"autoUpgradeMinorVersion\":true,\"settings\":\"datapkteo\",\"protectedSettings\":\"datalwptfdy\",\"provisionAfterExtensions\":[]}],\"osDisk\":{}}}")
                .toObject(DeploymentConfiguration.class);
        Assertions.assertEquals("lupj", model.cloudServiceConfiguration().osFamily());
        Assertions.assertEquals("hfxobbcswsrtj", model.cloudServiceConfiguration().osVersion());
        Assertions.assertEquals("lrbpbewtghfgbl", model.virtualMachineConfiguration().imageReference().publisher());
        Assertions.assertEquals("wxzvlvqhjkb", model.virtualMachineConfiguration().imageReference().offer());
        Assertions.assertEquals("ibtnmxiebwwaloay", model.virtualMachineConfiguration().imageReference().sku());
        Assertions.assertEquals("gwrtzju", model.virtualMachineConfiguration().imageReference().version());
        Assertions.assertEquals("wyzmhtxon", model.virtualMachineConfiguration().imageReference().id());
        Assertions.assertEquals("mtsavjcbpwxqp", model.virtualMachineConfiguration().nodeAgentSkuId());
        Assertions
            .assertEquals(true, model.virtualMachineConfiguration().windowsConfiguration().enableAutomaticUpdates());
        Assertions.assertEquals(810124654, model.virtualMachineConfiguration().dataDisks().get(0).lun());
        Assertions.assertEquals(CachingType.NONE, model.virtualMachineConfiguration().dataDisks().get(0).caching());
        Assertions.assertEquals(1935483255, model.virtualMachineConfiguration().dataDisks().get(0).diskSizeGB());
        Assertions
            .assertEquals(
                StorageAccountType.PREMIUM_LRS,
                model.virtualMachineConfiguration().dataDisks().get(0).storageAccountType());
        Assertions.assertEquals("riwwroy", model.virtualMachineConfiguration().licenseType());
        Assertions
            .assertEquals(
                "rmcqiby", model.virtualMachineConfiguration().containerConfiguration().containerImageNames().get(0));
        Assertions
            .assertEquals(
                DiskEncryptionTarget.TEMPORARY_DISK,
                model.virtualMachineConfiguration().diskEncryptionConfiguration().targets().get(0));
        Assertions
            .assertEquals(
                NodePlacementPolicyType.ZONAL,
                model.virtualMachineConfiguration().nodePlacementConfiguration().policy());
        Assertions.assertEquals("lxkvu", model.virtualMachineConfiguration().extensions().get(0).name());
        Assertions
            .assertEquals("fhzovawjvzunluth", model.virtualMachineConfiguration().extensions().get(0).publisher());
        Assertions.assertEquals("n", model.virtualMachineConfiguration().extensions().get(0).type());
        Assertions
            .assertEquals("nxipeil", model.virtualMachineConfiguration().extensions().get(0).typeHandlerVersion());
        Assertions
            .assertEquals(false, model.virtualMachineConfiguration().extensions().get(0).autoUpgradeMinorVersion());
    }

    @Test
    public void testSerialize() {
        DeploymentConfiguration model =
            new DeploymentConfiguration()
                .withCloudServiceConfiguration(
                    new CloudServiceConfiguration().withOsFamily("lupj").withOsVersion("hfxobbcswsrtj"))
                .withVirtualMachineConfiguration(
                    new VirtualMachineConfiguration()
                        .withImageReference(
                            new ImageReference()
                                .withPublisher("lrbpbewtghfgbl")
                                .withOffer("wxzvlvqhjkb")
                                .withSku("ibtnmxiebwwaloay")
                                .withVersion("gwrtzju")
                                .withId("wyzmhtxon"))
                        .withNodeAgentSkuId("mtsavjcbpwxqp")
                        .withWindowsConfiguration(new WindowsConfiguration().withEnableAutomaticUpdates(true))
                        .withDataDisks(
                            Arrays
                                .asList(
                                    new DataDisk()
                                        .withLun(810124654)
                                        .withCaching(CachingType.NONE)
                                        .withDiskSizeGB(1935483255)
                                        .withStorageAccountType(StorageAccountType.PREMIUM_LRS),
                                    new DataDisk()
                                        .withLun(2067966148)
                                        .withCaching(CachingType.READ_WRITE)
                                        .withDiskSizeGB(499230067)
                                        .withStorageAccountType(StorageAccountType.PREMIUM_LRS),
                                    new DataDisk()
                                        .withLun(1448281883)
                                        .withCaching(CachingType.READ_ONLY)
                                        .withDiskSizeGB(1468047146)
                                        .withStorageAccountType(StorageAccountType.PREMIUM_LRS)))
                        .withLicenseType("riwwroy")
                        .withContainerConfiguration(
                            new ContainerConfiguration()
                                .withContainerImageNames(Arrays.asList("rmcqiby", "nojvknmefqsg", "vah", "pjyzhpv"))
                                .withContainerRegistries(Arrays.asList()))
                        .withDiskEncryptionConfiguration(
                            new DiskEncryptionConfiguration()
                                .withTargets(
                                    Arrays
                                        .asList(
                                            DiskEncryptionTarget.TEMPORARY_DISK,
                                            DiskEncryptionTarget.TEMPORARY_DISK,
                                            DiskEncryptionTarget.OS_DISK)))
                        .withNodePlacementConfiguration(
                            new NodePlacementConfiguration().withPolicy(NodePlacementPolicyType.ZONAL))
                        .withExtensions(
                            Arrays
                                .asList(
                                    new VMExtension()
                                        .withName("lxkvu")
                                        .withPublisher("fhzovawjvzunluth")
                                        .withType("n")
                                        .withTypeHandlerVersion("nxipeil")
                                        .withAutoUpgradeMinorVersion(false)
                                        .withSettings("dataaejxd")
                                        .withProtectedSettings("datatskzbbtdzumveek")
                                        .withProvisionAfterExtensions(Arrays.asList()),
                                    new VMExtension()
                                        .withName("wozuhkf")
                                        .withPublisher("bsjyofdx")
                                        .withType("uusdttouwa")
                                        .withTypeHandlerVersion("ekqvkeln")
                                        .withAutoUpgradeMinorVersion(true)
                                        .withSettings("dataxwyjsflhhc")
                                        .withProtectedSettings("datalnjixisxya")
                                        .withProvisionAfterExtensions(Arrays.asList()),
                                    new VMExtension()
                                        .withName("oyaqcslyjpkiid")
                                        .withPublisher("yexz")
                                        .withType("eli")
                                        .withTypeHandlerVersion("nr")
                                        .withAutoUpgradeMinorVersion(true)
                                        .withSettings("datalhbnxkna")
                                        .withProtectedSettings("dataulppggdtpnapnyir")
                                        .withProvisionAfterExtensions(Arrays.asList()),
                                    new VMExtension()
                                        .withName("uhpigvp")
                                        .withPublisher("ylgqgitxmedjvcsl")
                                        .withType("n")
                                        .withTypeHandlerVersion("wncwzzhxgktrmg")
                                        .withAutoUpgradeMinorVersion(true)
                                        .withSettings("datapkteo")
                                        .withProtectedSettings("datalwptfdy")
                                        .withProvisionAfterExtensions(Arrays.asList())))
                        .withOsDisk(new OSDisk()));
        model = BinaryData.fromObject(model).toObject(DeploymentConfiguration.class);
        Assertions.assertEquals("lupj", model.cloudServiceConfiguration().osFamily());
        Assertions.assertEquals("hfxobbcswsrtj", model.cloudServiceConfiguration().osVersion());
        Assertions.assertEquals("lrbpbewtghfgbl", model.virtualMachineConfiguration().imageReference().publisher());
        Assertions.assertEquals("wxzvlvqhjkb", model.virtualMachineConfiguration().imageReference().offer());
        Assertions.assertEquals("ibtnmxiebwwaloay", model.virtualMachineConfiguration().imageReference().sku());
        Assertions.assertEquals("gwrtzju", model.virtualMachineConfiguration().imageReference().version());
        Assertions.assertEquals("wyzmhtxon", model.virtualMachineConfiguration().imageReference().id());
        Assertions.assertEquals("mtsavjcbpwxqp", model.virtualMachineConfiguration().nodeAgentSkuId());
        Assertions
            .assertEquals(true, model.virtualMachineConfiguration().windowsConfiguration().enableAutomaticUpdates());
        Assertions.assertEquals(810124654, model.virtualMachineConfiguration().dataDisks().get(0).lun());
        Assertions.assertEquals(CachingType.NONE, model.virtualMachineConfiguration().dataDisks().get(0).caching());
        Assertions.assertEquals(1935483255, model.virtualMachineConfiguration().dataDisks().get(0).diskSizeGB());
        Assertions
            .assertEquals(
                StorageAccountType.PREMIUM_LRS,
                model.virtualMachineConfiguration().dataDisks().get(0).storageAccountType());
        Assertions.assertEquals("riwwroy", model.virtualMachineConfiguration().licenseType());
        Assertions
            .assertEquals(
                "rmcqiby", model.virtualMachineConfiguration().containerConfiguration().containerImageNames().get(0));
        Assertions
            .assertEquals(
                DiskEncryptionTarget.TEMPORARY_DISK,
                model.virtualMachineConfiguration().diskEncryptionConfiguration().targets().get(0));
        Assertions
            .assertEquals(
                NodePlacementPolicyType.ZONAL,
                model.virtualMachineConfiguration().nodePlacementConfiguration().policy());
        Assertions.assertEquals("lxkvu", model.virtualMachineConfiguration().extensions().get(0).name());
        Assertions
            .assertEquals("fhzovawjvzunluth", model.virtualMachineConfiguration().extensions().get(0).publisher());
        Assertions.assertEquals("n", model.virtualMachineConfiguration().extensions().get(0).type());
        Assertions
            .assertEquals("nxipeil", model.virtualMachineConfiguration().extensions().get(0).typeHandlerVersion());
        Assertions
            .assertEquals(false, model.virtualMachineConfiguration().extensions().get(0).autoUpgradeMinorVersion());
    }
}
