// 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.CustomImageProperties;
import com.azure.resourcemanager.devtestlabs.models.CustomImageOsType;
import com.azure.resourcemanager.devtestlabs.models.CustomImagePropertiesCustom;
import com.azure.resourcemanager.devtestlabs.models.CustomImagePropertiesFromPlan;
import com.azure.resourcemanager.devtestlabs.models.CustomImagePropertiesFromVm;
import com.azure.resourcemanager.devtestlabs.models.DataDiskStorageTypeInfo;
import com.azure.resourcemanager.devtestlabs.models.LinuxOsInfo;
import com.azure.resourcemanager.devtestlabs.models.LinuxOsState;
import com.azure.resourcemanager.devtestlabs.models.StorageType;
import com.azure.resourcemanager.devtestlabs.models.WindowsOsInfo;
import com.azure.resourcemanager.devtestlabs.models.WindowsOsState;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class CustomImagePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CustomImageProperties model =
            BinaryData
                .fromString(
                    "{\"vm\":{\"sourceVmId\":\"tkl\",\"windowsOsInfo\":{\"windowsOsState\":\"SysprepApplied\"},\"linuxOsInfo\":{\"linuxOsState\":\"DeprovisionRequested\"}},\"vhd\":{\"imageName\":\"an\",\"sysPrep\":false,\"osType\":\"Windows\"},\"description\":\"ph\",\"author\":\"ulpjr\",\"creationDate\":\"2021-04-09T11:20:33Z\",\"managedImageId\":\"l\",\"managedSnapshotId\":\"imjwosyt\",\"dataDiskStorageInfo\":[{\"lun\":\"skfc\",\"storageType\":\"StandardSSD\"}],\"customImagePlan\":{\"id\":\"iekkezz\",\"publisher\":\"hlyfjhdgqgg\",\"offer\":\"dunyg\"},\"isPlanAuthorized\":true,\"provisioningState\":\"db\",\"uniqueIdentifier\":\"atpxl\"}")
                .toObject(CustomImageProperties.class);
        Assertions.assertEquals("tkl", model.vm().sourceVmId());
        Assertions.assertEquals(WindowsOsState.SYSPREP_APPLIED, model.vm().windowsOsInfo().windowsOsState());
        Assertions.assertEquals(LinuxOsState.DEPROVISION_REQUESTED, model.vm().linuxOsInfo().linuxOsState());
        Assertions.assertEquals("an", model.vhd().imageName());
        Assertions.assertEquals(false, model.vhd().sysPrep());
        Assertions.assertEquals(CustomImageOsType.WINDOWS, model.vhd().osType());
        Assertions.assertEquals("ph", model.description());
        Assertions.assertEquals("ulpjr", model.author());
        Assertions.assertEquals("l", model.managedImageId());
        Assertions.assertEquals("imjwosyt", model.managedSnapshotId());
        Assertions.assertEquals("skfc", model.dataDiskStorageInfo().get(0).lun());
        Assertions.assertEquals(StorageType.STANDARD_SSD, model.dataDiskStorageInfo().get(0).storageType());
        Assertions.assertEquals("iekkezz", model.customImagePlan().id());
        Assertions.assertEquals("hlyfjhdgqgg", model.customImagePlan().publisher());
        Assertions.assertEquals("dunyg", model.customImagePlan().offer());
        Assertions.assertEquals(true, model.isPlanAuthorized());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CustomImageProperties model =
            new CustomImageProperties()
                .withVm(
                    new CustomImagePropertiesFromVm()
                        .withSourceVmId("tkl")
                        .withWindowsOsInfo(new WindowsOsInfo().withWindowsOsState(WindowsOsState.SYSPREP_APPLIED))
                        .withLinuxOsInfo(new LinuxOsInfo().withLinuxOsState(LinuxOsState.DEPROVISION_REQUESTED)))
                .withVhd(
                    new CustomImagePropertiesCustom()
                        .withImageName("an")
                        .withSysPrep(false)
                        .withOsType(CustomImageOsType.WINDOWS))
                .withDescription("ph")
                .withAuthor("ulpjr")
                .withManagedImageId("l")
                .withManagedSnapshotId("imjwosyt")
                .withDataDiskStorageInfo(
                    Arrays
                        .asList(
                            new DataDiskStorageTypeInfo().withLun("skfc").withStorageType(StorageType.STANDARD_SSD)))
                .withCustomImagePlan(
                    new CustomImagePropertiesFromPlan()
                        .withId("iekkezz")
                        .withPublisher("hlyfjhdgqgg")
                        .withOffer("dunyg"))
                .withIsPlanAuthorized(true);
        model = BinaryData.fromObject(model).toObject(CustomImageProperties.class);
        Assertions.assertEquals("tkl", model.vm().sourceVmId());
        Assertions.assertEquals(WindowsOsState.SYSPREP_APPLIED, model.vm().windowsOsInfo().windowsOsState());
        Assertions.assertEquals(LinuxOsState.DEPROVISION_REQUESTED, model.vm().linuxOsInfo().linuxOsState());
        Assertions.assertEquals("an", model.vhd().imageName());
        Assertions.assertEquals(false, model.vhd().sysPrep());
        Assertions.assertEquals(CustomImageOsType.WINDOWS, model.vhd().osType());
        Assertions.assertEquals("ph", model.description());
        Assertions.assertEquals("ulpjr", model.author());
        Assertions.assertEquals("l", model.managedImageId());
        Assertions.assertEquals("imjwosyt", model.managedSnapshotId());
        Assertions.assertEquals("skfc", model.dataDiskStorageInfo().get(0).lun());
        Assertions.assertEquals(StorageType.STANDARD_SSD, model.dataDiskStorageInfo().get(0).storageType());
        Assertions.assertEquals("iekkezz", model.customImagePlan().id());
        Assertions.assertEquals("hlyfjhdgqgg", model.customImagePlan().publisher());
        Assertions.assertEquals("dunyg", model.customImagePlan().offer());
        Assertions.assertEquals(true, model.isPlanAuthorized());
    }
}
