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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.fluent.models.ScheduleInner;
import com.azure.resourcemanager.machinelearning.models.ScheduleActionBase;
import com.azure.resourcemanager.machinelearning.models.ScheduleProperties;
import com.azure.resourcemanager.machinelearning.models.TriggerBase;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ScheduleInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScheduleInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"action\":{\"actionType\":\"ScheduleActionBase\"},\"displayName\":\"quvre\",\"isEnabled\":true,\"provisioningState\":\"Succeeded\",\"trigger\":{\"triggerType\":\"TriggerBase\",\"endTime\":\"vsujztczytqjtwh\",\"startTime\":\"unfprnjletlxs\",\"timeZone\":\"pddouifamowaziyn\"},\"description\":\"lqwzdvpiwhxqsz\",\"properties\":{\"m\":\"aajquhuxylrj\",\"kfkyjp\":\"ygjbmzyospspsh\",\"pssdfppyogtie\":\"sp\"},\"tags\":{\"munjdxvglnkvx\":\"tvczkcnyxr\",\"khpzvuqdflv\":\"xpaglqivbgkc\",\"xtiv\":\"niypfpubcpzg\",\"nidibgqjxg\":\"j\"}},\"id\":\"r\",\"name\":\"govfgpikqmhhaow\",\"type\":\"rmzvupo\"}")
                .toObject(ScheduleInner.class);
        Assertions.assertEquals("lqwzdvpiwhxqsz", model.properties().description());
        Assertions.assertEquals("aajquhuxylrj", model.properties().properties().get("m"));
        Assertions.assertEquals("tvczkcnyxr", model.properties().tags().get("munjdxvglnkvx"));
        Assertions.assertEquals("quvre", model.properties().displayName());
        Assertions.assertEquals(true, model.properties().isEnabled());
        Assertions.assertEquals("vsujztczytqjtwh", model.properties().trigger().endTime());
        Assertions.assertEquals("unfprnjletlxs", model.properties().trigger().startTime());
        Assertions.assertEquals("pddouifamowaziyn", model.properties().trigger().timeZone());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduleInner model =
            new ScheduleInner()
                .withProperties(
                    new ScheduleProperties()
                        .withDescription("lqwzdvpiwhxqsz")
                        .withProperties(mapOf("m", "aajquhuxylrj", "kfkyjp", "ygjbmzyospspsh", "pssdfppyogtie", "sp"))
                        .withTags(
                            mapOf(
                                "munjdxvglnkvx",
                                "tvczkcnyxr",
                                "khpzvuqdflv",
                                "xpaglqivbgkc",
                                "xtiv",
                                "niypfpubcpzg",
                                "nidibgqjxg",
                                "j"))
                        .withAction(new ScheduleActionBase())
                        .withDisplayName("quvre")
                        .withIsEnabled(true)
                        .withTrigger(
                            new TriggerBase()
                                .withEndTime("vsujztczytqjtwh")
                                .withStartTime("unfprnjletlxs")
                                .withTimeZone("pddouifamowaziyn")));
        model = BinaryData.fromObject(model).toObject(ScheduleInner.class);
        Assertions.assertEquals("lqwzdvpiwhxqsz", model.properties().description());
        Assertions.assertEquals("aajquhuxylrj", model.properties().properties().get("m"));
        Assertions.assertEquals("tvczkcnyxr", model.properties().tags().get("munjdxvglnkvx"));
        Assertions.assertEquals("quvre", model.properties().displayName());
        Assertions.assertEquals(true, model.properties().isEnabled());
        Assertions.assertEquals("vsujztczytqjtwh", model.properties().trigger().endTime());
        Assertions.assertEquals("unfprnjletlxs", model.properties().trigger().startTime());
        Assertions.assertEquals("pddouifamowaziyn", model.properties().trigger().timeZone());
    }

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