// 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.models.DayDetails;
import com.azure.resourcemanager.devtestlabs.models.EnableStatus;
import com.azure.resourcemanager.devtestlabs.models.HourDetails;
import com.azure.resourcemanager.devtestlabs.models.NotificationSettings;
import com.azure.resourcemanager.devtestlabs.models.ScheduleCreationParameter;
import com.azure.resourcemanager.devtestlabs.models.WeekDetails;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ScheduleCreationParameterTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ScheduleCreationParameter model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"status\":\"Enabled\",\"taskType\":\"kpzi\",\"weeklyRecurrence\":{\"weekdays\":[\"anlfzxiavrmbz\"],\"time\":\"okixrjqcir\"},\"dailyRecurrence\":{\"time\":\"frl\"},\"hourlyRecurrence\":{\"minute\":1054852433},\"timeZoneId\":\"nwoiind\",\"notificationSettings\":{\"status\":\"Enabled\",\"timeInMinutes\":2003190846,\"webhookUrl\":\"wbtlhflsjcdh\",\"emailRecipient\":\"fjvfbgofeljagr\",\"notificationLocale\":\"qhl\"},\"targetResourceId\":\"riiiojnalghfkv\"},\"name\":\"sexso\",\"location\":\"el\",\"tags\":{\"wws\":\"hahhxvrhmzkwpj\",\"qxujxukndxd\":\"ughftqsx\",\"syqtfi\":\"grjguufzd\",\"phoszqz\":\"whbotzingamv\"}}")
                .toObject(ScheduleCreationParameter.class);
        Assertions.assertEquals("sexso", model.name());
        Assertions.assertEquals("hahhxvrhmzkwpj", model.tags().get("wws"));
        Assertions.assertEquals(EnableStatus.ENABLED, model.status());
        Assertions.assertEquals("kpzi", model.taskType());
        Assertions.assertEquals("anlfzxiavrmbz", model.weeklyRecurrence().weekdays().get(0));
        Assertions.assertEquals("okixrjqcir", model.weeklyRecurrence().time());
        Assertions.assertEquals("frl", model.dailyRecurrence().time());
        Assertions.assertEquals(1054852433, model.hourlyRecurrence().minute());
        Assertions.assertEquals("nwoiind", model.timeZoneId());
        Assertions.assertEquals(EnableStatus.ENABLED, model.notificationSettings().status());
        Assertions.assertEquals(2003190846, model.notificationSettings().timeInMinutes());
        Assertions.assertEquals("wbtlhflsjcdh", model.notificationSettings().webhookUrl());
        Assertions.assertEquals("fjvfbgofeljagr", model.notificationSettings().emailRecipient());
        Assertions.assertEquals("qhl", model.notificationSettings().notificationLocale());
        Assertions.assertEquals("riiiojnalghfkv", model.targetResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduleCreationParameter model =
            new ScheduleCreationParameter()
                .withName("sexso")
                .withTags(
                    mapOf(
                        "wws",
                        "hahhxvrhmzkwpj",
                        "qxujxukndxd",
                        "ughftqsx",
                        "syqtfi",
                        "grjguufzd",
                        "phoszqz",
                        "whbotzingamv"))
                .withStatus(EnableStatus.ENABLED)
                .withTaskType("kpzi")
                .withWeeklyRecurrence(
                    new WeekDetails().withWeekdays(Arrays.asList("anlfzxiavrmbz")).withTime("okixrjqcir"))
                .withDailyRecurrence(new DayDetails().withTime("frl"))
                .withHourlyRecurrence(new HourDetails().withMinute(1054852433))
                .withTimeZoneId("nwoiind")
                .withNotificationSettings(
                    new NotificationSettings()
                        .withStatus(EnableStatus.ENABLED)
                        .withTimeInMinutes(2003190846)
                        .withWebhookUrl("wbtlhflsjcdh")
                        .withEmailRecipient("fjvfbgofeljagr")
                        .withNotificationLocale("qhl"))
                .withTargetResourceId("riiiojnalghfkv");
        model = BinaryData.fromObject(model).toObject(ScheduleCreationParameter.class);
        Assertions.assertEquals("sexso", model.name());
        Assertions.assertEquals("hahhxvrhmzkwpj", model.tags().get("wws"));
        Assertions.assertEquals(EnableStatus.ENABLED, model.status());
        Assertions.assertEquals("kpzi", model.taskType());
        Assertions.assertEquals("anlfzxiavrmbz", model.weeklyRecurrence().weekdays().get(0));
        Assertions.assertEquals("okixrjqcir", model.weeklyRecurrence().time());
        Assertions.assertEquals("frl", model.dailyRecurrence().time());
        Assertions.assertEquals(1054852433, model.hourlyRecurrence().minute());
        Assertions.assertEquals("nwoiind", model.timeZoneId());
        Assertions.assertEquals(EnableStatus.ENABLED, model.notificationSettings().status());
        Assertions.assertEquals(2003190846, model.notificationSettings().timeInMinutes());
        Assertions.assertEquals("wbtlhflsjcdh", model.notificationSettings().webhookUrl());
        Assertions.assertEquals("fjvfbgofeljagr", model.notificationSettings().emailRecipient());
        Assertions.assertEquals("qhl", model.notificationSettings().notificationLocale());
        Assertions.assertEquals("riiiojnalghfkv", model.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;
    }
}
