// 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.LabInner;
import com.azure.resourcemanager.devtestlabs.models.EnableStatus;
import com.azure.resourcemanager.devtestlabs.models.EnvironmentPermission;
import com.azure.resourcemanager.devtestlabs.models.LabAnnouncementProperties;
import com.azure.resourcemanager.devtestlabs.models.LabSupportProperties;
import com.azure.resourcemanager.devtestlabs.models.PremiumDataDisk;
import com.azure.resourcemanager.devtestlabs.models.StorageType;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class LabInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LabInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"defaultStorageAccount\":\"yypnddhsgcbacphe\",\"defaultPremiumStorageAccount\":\"ot\",\"artifactsStorageAccount\":\"qgoulznd\",\"premiumDataDiskStorageAccount\":\"kwy\",\"vaultName\":\"gfgibm\",\"labStorageType\":\"Standard\",\"mandatoryArtifactsResourceIdsLinux\":[\"eqsrxybzqqedqyt\",\"ciqfou\",\"lmmnkzsmodmglo\",\"gpbkwtmut\"],\"mandatoryArtifactsResourceIdsWindows\":[\"ktapspwgcuertu\",\"kdosvqw\",\"bmdg\",\"bjf\"],\"createdDate\":\"2021-04-14T03:32:51Z\",\"premiumDataDisks\":\"Enabled\",\"environmentPermission\":\"Reader\",\"announcement\":{\"title\":\"ppbhtqqrolfp\",\"markdown\":\"s\",\"enabled\":\"Enabled\",\"expirationDate\":\"2021-02-03T23:40:53Z\",\"expired\":true,\"provisioningState\":\"gjyjgzjaoyfhrtxi\",\"uniqueIdentifier\":\"erkujys\"},\"support\":{\"enabled\":\"Enabled\",\"markdown\":\"vfqawrlyxwjkcpr\"},\"vmCreationResourceGroup\":\"wbxgjvt\",\"publicIpId\":\"p\",\"loadBalancerId\":\"szdnr\",\"networkSecurityGroupId\":\"qguhmuo\",\"extendedProperties\":{\"gazxuf\":\"prwzwbnguitnwui\"},\"provisioningState\":\"uckyf\",\"uniqueIdentifier\":\"rfidfvzwdz\"},\"location\":\"htymw\",\"tags\":{\"aop\":\"kfthwxmntei\",\"jcmmxdcufufsrp\":\"km\",\"sgfyccsnew\":\"mzidnsezcxtb\"},\"id\":\"dwzjeiach\",\"name\":\"oosflnr\",\"type\":\"sfqpteehz\"}")
                .toObject(LabInner.class);
        Assertions.assertEquals("htymw", model.location());
        Assertions.assertEquals("kfthwxmntei", model.tags().get("aop"));
        Assertions.assertEquals(StorageType.STANDARD, model.labStorageType());
        Assertions.assertEquals("eqsrxybzqqedqyt", model.mandatoryArtifactsResourceIdsLinux().get(0));
        Assertions.assertEquals("ktapspwgcuertu", model.mandatoryArtifactsResourceIdsWindows().get(0));
        Assertions.assertEquals(PremiumDataDisk.ENABLED, model.premiumDataDisks());
        Assertions.assertEquals(EnvironmentPermission.READER, model.environmentPermission());
        Assertions.assertEquals("ppbhtqqrolfp", model.announcement().title());
        Assertions.assertEquals("s", model.announcement().markdown());
        Assertions.assertEquals(EnableStatus.ENABLED, model.announcement().enabled());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-03T23:40:53Z"), model.announcement().expirationDate());
        Assertions.assertEquals(true, model.announcement().expired());
        Assertions.assertEquals(EnableStatus.ENABLED, model.support().enabled());
        Assertions.assertEquals("vfqawrlyxwjkcpr", model.support().markdown());
        Assertions.assertEquals("prwzwbnguitnwui", model.extendedProperties().get("gazxuf"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LabInner model =
            new LabInner()
                .withLocation("htymw")
                .withTags(mapOf("aop", "kfthwxmntei", "jcmmxdcufufsrp", "km", "sgfyccsnew", "mzidnsezcxtb"))
                .withLabStorageType(StorageType.STANDARD)
                .withMandatoryArtifactsResourceIdsLinux(
                    Arrays.asList("eqsrxybzqqedqyt", "ciqfou", "lmmnkzsmodmglo", "gpbkwtmut"))
                .withMandatoryArtifactsResourceIdsWindows(Arrays.asList("ktapspwgcuertu", "kdosvqw", "bmdg", "bjf"))
                .withPremiumDataDisks(PremiumDataDisk.ENABLED)
                .withEnvironmentPermission(EnvironmentPermission.READER)
                .withAnnouncement(
                    new LabAnnouncementProperties()
                        .withTitle("ppbhtqqrolfp")
                        .withMarkdown("s")
                        .withEnabled(EnableStatus.ENABLED)
                        .withExpirationDate(OffsetDateTime.parse("2021-02-03T23:40:53Z"))
                        .withExpired(true))
                .withSupport(
                    new LabSupportProperties().withEnabled(EnableStatus.ENABLED).withMarkdown("vfqawrlyxwjkcpr"))
                .withExtendedProperties(mapOf("gazxuf", "prwzwbnguitnwui"));
        model = BinaryData.fromObject(model).toObject(LabInner.class);
        Assertions.assertEquals("htymw", model.location());
        Assertions.assertEquals("kfthwxmntei", model.tags().get("aop"));
        Assertions.assertEquals(StorageType.STANDARD, model.labStorageType());
        Assertions.assertEquals("eqsrxybzqqedqyt", model.mandatoryArtifactsResourceIdsLinux().get(0));
        Assertions.assertEquals("ktapspwgcuertu", model.mandatoryArtifactsResourceIdsWindows().get(0));
        Assertions.assertEquals(PremiumDataDisk.ENABLED, model.premiumDataDisks());
        Assertions.assertEquals(EnvironmentPermission.READER, model.environmentPermission());
        Assertions.assertEquals("ppbhtqqrolfp", model.announcement().title());
        Assertions.assertEquals("s", model.announcement().markdown());
        Assertions.assertEquals(EnableStatus.ENABLED, model.announcement().enabled());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-03T23:40:53Z"), model.announcement().expirationDate());
        Assertions.assertEquals(true, model.announcement().expired());
        Assertions.assertEquals(EnableStatus.ENABLED, model.support().enabled());
        Assertions.assertEquals("vfqawrlyxwjkcpr", model.support().markdown());
        Assertions.assertEquals("prwzwbnguitnwui", model.extendedProperties().get("gazxuf"));
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
