// 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.ApplicableSchedulePropertiesInner;
import com.azure.resourcemanager.devtestlabs.fluent.models.ScheduleInner;
import com.azure.resourcemanager.devtestlabs.models.EnableStatus;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ApplicableSchedulePropertiesInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ApplicableSchedulePropertiesInner model =
            BinaryData
                .fromString(
                    "{\"labVmsShutdown\":{\"properties\":{\"status\":\"Enabled\",\"taskType\":\"mq\",\"timeZoneId\":\"lajrnwxacevehj\",\"createdDate\":\"2021-05-11T20:12:40Z\",\"targetResourceId\":\"afgaoqlt\",\"provisioningState\":\"eyl\",\"uniqueIdentifier\":\"mfgvxirpghriypo\"},\"location\":\"eyhlqhykprl\",\"tags\":{\"fuxtyasiibmiybnn\":\"nuciqdsmexiit\",\"hnmgixhcm\":\"stgnl\",\"rhc\":\"vmqfoud\"},\"id\":\"yyprotwyp\",\"name\":\"ndm\",\"type\":\"xhugcm\"},\"labVmsStartup\":{\"properties\":{\"status\":\"Enabled\",\"taskType\":\"gorbmftpm\",\"timeZoneId\":\"ltfvnz\",\"createdDate\":\"2021-02-22T19:45:43Z\",\"targetResourceId\":\"tpvopvpbdb\",\"provisioningState\":\"gqqihedsvqwt\",\"uniqueIdentifier\":\"ky\"},\"location\":\"bcysih\",\"tags\":{\"hohsd\":\"cw\",\"mcmuapc\":\"mcdzsufcohdxbz\"},\"id\":\"hdbevwqqxeyskon\",\"name\":\"zinkfkbgbzbowxeq\",\"type\":\"clj\"}}")
                .toObject(ApplicableSchedulePropertiesInner.class);
        Assertions.assertEquals("eyhlqhykprl", model.labVmsShutdown().location());
        Assertions.assertEquals("nuciqdsmexiit", model.labVmsShutdown().tags().get("fuxtyasiibmiybnn"));
        Assertions.assertEquals(EnableStatus.ENABLED, model.labVmsShutdown().status());
        Assertions.assertEquals("mq", model.labVmsShutdown().taskType());
        Assertions.assertEquals("lajrnwxacevehj", model.labVmsShutdown().timeZoneId());
        Assertions.assertEquals("afgaoqlt", model.labVmsShutdown().targetResourceId());
        Assertions.assertEquals("bcysih", model.labVmsStartup().location());
        Assertions.assertEquals("cw", model.labVmsStartup().tags().get("hohsd"));
        Assertions.assertEquals(EnableStatus.ENABLED, model.labVmsStartup().status());
        Assertions.assertEquals("gorbmftpm", model.labVmsStartup().taskType());
        Assertions.assertEquals("ltfvnz", model.labVmsStartup().timeZoneId());
        Assertions.assertEquals("tpvopvpbdb", model.labVmsStartup().targetResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ApplicableSchedulePropertiesInner model =
            new ApplicableSchedulePropertiesInner()
                .withLabVmsShutdown(
                    new ScheduleInner()
                        .withLocation("eyhlqhykprl")
                        .withTags(mapOf("fuxtyasiibmiybnn", "nuciqdsmexiit", "hnmgixhcm", "stgnl", "rhc", "vmqfoud"))
                        .withStatus(EnableStatus.ENABLED)
                        .withTaskType("mq")
                        .withTimeZoneId("lajrnwxacevehj")
                        .withTargetResourceId("afgaoqlt"))
                .withLabVmsStartup(
                    new ScheduleInner()
                        .withLocation("bcysih")
                        .withTags(mapOf("hohsd", "cw", "mcmuapc", "mcdzsufcohdxbz"))
                        .withStatus(EnableStatus.ENABLED)
                        .withTaskType("gorbmftpm")
                        .withTimeZoneId("ltfvnz")
                        .withTargetResourceId("tpvopvpbdb"));
        model = BinaryData.fromObject(model).toObject(ApplicableSchedulePropertiesInner.class);
        Assertions.assertEquals("eyhlqhykprl", model.labVmsShutdown().location());
        Assertions.assertEquals("nuciqdsmexiit", model.labVmsShutdown().tags().get("fuxtyasiibmiybnn"));
        Assertions.assertEquals(EnableStatus.ENABLED, model.labVmsShutdown().status());
        Assertions.assertEquals("mq", model.labVmsShutdown().taskType());
        Assertions.assertEquals("lajrnwxacevehj", model.labVmsShutdown().timeZoneId());
        Assertions.assertEquals("afgaoqlt", model.labVmsShutdown().targetResourceId());
        Assertions.assertEquals("bcysih", model.labVmsStartup().location());
        Assertions.assertEquals("cw", model.labVmsStartup().tags().get("hohsd"));
        Assertions.assertEquals(EnableStatus.ENABLED, model.labVmsStartup().status());
        Assertions.assertEquals("gorbmftpm", model.labVmsStartup().taskType());
        Assertions.assertEquals("ltfvnz", model.labVmsStartup().timeZoneId());
        Assertions.assertEquals("tpvopvpbdb", model.labVmsStartup().targetResourceId());
    }

    @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;
    }
}
