// 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.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 SchedulePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScheduleProperties model =
            BinaryData
                .fromString(
                    "{\"action\":{\"actionType\":\"ScheduleActionBase\"},\"displayName\":\"zdfuydzvkfvxcnqm\",\"isEnabled\":false,\"provisioningState\":\"Creating\",\"trigger\":{\"triggerType\":\"TriggerBase\",\"endTime\":\"kmvkhl\",\"startTime\":\"dhbemzqkzszu\",\"timeZone\":\"wtglxx\"},\"description\":\"jfpgpicrmn\",\"properties\":{\"vpqcb\":\"gmqgjs\",\"s\":\"rmbodt\"},\"tags\":{\"xousxauzl\":\"vriibakclacjfr\",\"wohqfzizvu\":\"vsg\",\"vmribiat\":\"mmkjsvthnwpztek\"}}")
                .toObject(ScheduleProperties.class);
        Assertions.assertEquals("jfpgpicrmn", model.description());
        Assertions.assertEquals("gmqgjs", model.properties().get("vpqcb"));
        Assertions.assertEquals("vriibakclacjfr", model.tags().get("xousxauzl"));
        Assertions.assertEquals("zdfuydzvkfvxcnqm", model.displayName());
        Assertions.assertEquals(false, model.isEnabled());
        Assertions.assertEquals("kmvkhl", model.trigger().endTime());
        Assertions.assertEquals("dhbemzqkzszu", model.trigger().startTime());
        Assertions.assertEquals("wtglxx", model.trigger().timeZone());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduleProperties model =
            new ScheduleProperties()
                .withDescription("jfpgpicrmn")
                .withProperties(mapOf("vpqcb", "gmqgjs", "s", "rmbodt"))
                .withTags(mapOf("xousxauzl", "vriibakclacjfr", "wohqfzizvu", "vsg", "vmribiat", "mmkjsvthnwpztek"))
                .withAction(new ScheduleActionBase())
                .withDisplayName("zdfuydzvkfvxcnqm")
                .withIsEnabled(false)
                .withTrigger(
                    new TriggerBase().withEndTime("kmvkhl").withStartTime("dhbemzqkzszu").withTimeZone("wtglxx"));
        model = BinaryData.fromObject(model).toObject(ScheduleProperties.class);
        Assertions.assertEquals("jfpgpicrmn", model.description());
        Assertions.assertEquals("gmqgjs", model.properties().get("vpqcb"));
        Assertions.assertEquals("vriibakclacjfr", model.tags().get("xousxauzl"));
        Assertions.assertEquals("zdfuydzvkfvxcnqm", model.displayName());
        Assertions.assertEquals(false, model.isEnabled());
        Assertions.assertEquals("kmvkhl", model.trigger().endTime());
        Assertions.assertEquals("dhbemzqkzszu", model.trigger().startTime());
        Assertions.assertEquals("wtglxx", model.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;
    }
}
