// 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.ScheduleInner;
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.WeekDetails;
import java.util.Arrays;
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\":{\"status\":\"Disabled\",\"taskType\":\"pj\",\"weeklyRecurrence\":{\"weekdays\":[\"xazjpqyegual\",\"b\"],\"time\":\"hejjz\"},\"dailyRecurrence\":{\"time\":\"udgwdslfho\"},\"hourlyRecurrence\":{\"minute\":470013493},\"timeZoneId\":\"npwlbjnpg\",\"notificationSettings\":{\"status\":\"Disabled\",\"timeInMinutes\":1405360141,\"webhookUrl\":\"h\",\"emailRecipient\":\"ltyfsop\",\"notificationLocale\":\"suesnzw\"},\"createdDate\":\"2021-01-14T15:45:02Z\",\"targetResourceId\":\"avo\",\"provisioningState\":\"zdmohctbqvu\",\"uniqueIdentifier\":\"xdn\"},\"location\":\"nvowgujju\",\"tags\":{\"dyggdtjixhbku\":\"kcglhslaz\",\"fyexfwhy\":\"fqweykhmene\"},\"id\":\"cibvyvdcsitynn\",\"name\":\"amdecte\",\"type\":\"f\"}")
                .toObject(ScheduleInner.class);
        Assertions.assertEquals("nvowgujju", model.location());
        Assertions.assertEquals("kcglhslaz", model.tags().get("dyggdtjixhbku"));
        Assertions.assertEquals(EnableStatus.DISABLED, model.status());
        Assertions.assertEquals("pj", model.taskType());
        Assertions.assertEquals("xazjpqyegual", model.weeklyRecurrence().weekdays().get(0));
        Assertions.assertEquals("hejjz", model.weeklyRecurrence().time());
        Assertions.assertEquals("udgwdslfho", model.dailyRecurrence().time());
        Assertions.assertEquals(470013493, model.hourlyRecurrence().minute());
        Assertions.assertEquals("npwlbjnpg", model.timeZoneId());
        Assertions.assertEquals(EnableStatus.DISABLED, model.notificationSettings().status());
        Assertions.assertEquals(1405360141, model.notificationSettings().timeInMinutes());
        Assertions.assertEquals("h", model.notificationSettings().webhookUrl());
        Assertions.assertEquals("ltyfsop", model.notificationSettings().emailRecipient());
        Assertions.assertEquals("suesnzw", model.notificationSettings().notificationLocale());
        Assertions.assertEquals("avo", model.targetResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ScheduleInner model =
            new ScheduleInner()
                .withLocation("nvowgujju")
                .withTags(mapOf("dyggdtjixhbku", "kcglhslaz", "fyexfwhy", "fqweykhmene"))
                .withStatus(EnableStatus.DISABLED)
                .withTaskType("pj")
                .withWeeklyRecurrence(
                    new WeekDetails().withWeekdays(Arrays.asList("xazjpqyegual", "b")).withTime("hejjz"))
                .withDailyRecurrence(new DayDetails().withTime("udgwdslfho"))
                .withHourlyRecurrence(new HourDetails().withMinute(470013493))
                .withTimeZoneId("npwlbjnpg")
                .withNotificationSettings(
                    new NotificationSettings()
                        .withStatus(EnableStatus.DISABLED)
                        .withTimeInMinutes(1405360141)
                        .withWebhookUrl("h")
                        .withEmailRecipient("ltyfsop")
                        .withNotificationLocale("suesnzw"))
                .withTargetResourceId("avo");
        model = BinaryData.fromObject(model).toObject(ScheduleInner.class);
        Assertions.assertEquals("nvowgujju", model.location());
        Assertions.assertEquals("kcglhslaz", model.tags().get("dyggdtjixhbku"));
        Assertions.assertEquals(EnableStatus.DISABLED, model.status());
        Assertions.assertEquals("pj", model.taskType());
        Assertions.assertEquals("xazjpqyegual", model.weeklyRecurrence().weekdays().get(0));
        Assertions.assertEquals("hejjz", model.weeklyRecurrence().time());
        Assertions.assertEquals("udgwdslfho", model.dailyRecurrence().time());
        Assertions.assertEquals(470013493, model.hourlyRecurrence().minute());
        Assertions.assertEquals("npwlbjnpg", model.timeZoneId());
        Assertions.assertEquals(EnableStatus.DISABLED, model.notificationSettings().status());
        Assertions.assertEquals(1405360141, model.notificationSettings().timeInMinutes());
        Assertions.assertEquals("h", model.notificationSettings().webhookUrl());
        Assertions.assertEquals("ltyfsop", model.notificationSettings().emailRecipient());
        Assertions.assertEquals("suesnzw", model.notificationSettings().notificationLocale());
        Assertions.assertEquals("avo", 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;
    }
}
