// 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.ComputePowerAction;
import com.azure.resourcemanager.machinelearning.models.ComputeSchedules;
import com.azure.resourcemanager.machinelearning.models.ComputeStartStopSchedule;
import com.azure.resourcemanager.machinelearning.models.CronTrigger;
import com.azure.resourcemanager.machinelearning.models.RecurrenceFrequency;
import com.azure.resourcemanager.machinelearning.models.RecurrenceTrigger;
import com.azure.resourcemanager.machinelearning.models.ScheduleBase;
import com.azure.resourcemanager.machinelearning.models.ScheduleProvisioningState;
import com.azure.resourcemanager.machinelearning.models.ScheduleStatus;
import com.azure.resourcemanager.machinelearning.models.TriggerType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ComputeSchedulesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ComputeSchedules model =
            BinaryData
                .fromString(
                    "{\"computeStartStop\":[{\"id\":\"lxrzvhqjwtr\",\"provisioningStatus\":\"Completed\",\"status\":\"Disabled\",\"action\":\"Start\",\"triggerType\":\"Cron\",\"recurrence\":{\"triggerType\":\"Recurrence\",\"frequency\":\"Hour\",\"interval\":1941330764,\"endTime\":\"w\",\"startTime\":\"jsmwrokc\",\"timeZone\":\"fzzzwyjafitlhg\"},\"cron\":{\"triggerType\":\"Cron\",\"expression\":\"nuchlgmltxdwhmo\",\"endTime\":\"sgzv\",\"startTime\":\"snnjzfpafolpym\",\"timeZone\":\"mxq\"},\"schedule\":{\"id\":\"gpgdphtvdulaj\",\"provisioningStatus\":\"Provisioning\",\"status\":\"Enabled\"}},{\"id\":\"csrlzknmzl\",\"provisioningStatus\":\"Failed\",\"status\":\"Disabled\",\"action\":\"Start\",\"triggerType\":\"Cron\",\"recurrence\":{\"triggerType\":\"Recurrence\",\"frequency\":\"Hour\",\"interval\":794571898,\"endTime\":\"q\",\"startTime\":\"jhmqrhvthla\",\"timeZone\":\"dcxsmlz\"},\"cron\":{\"triggerType\":\"Cron\",\"expression\":\"zdtxetlgyd\",\"endTime\":\"qvlnnpxybafiqgea\",\"startTime\":\"bgj\",\"timeZone\":\"glklb\"},\"schedule\":{\"id\":\"idwcwvmzegjon\",\"provisioningStatus\":\"Provisioning\",\"status\":\"Disabled\"}},{\"id\":\"gdn\",\"provisioningStatus\":\"Failed\",\"status\":\"Disabled\",\"action\":\"Stop\",\"triggerType\":\"Cron\",\"recurrence\":{\"triggerType\":\"Recurrence\",\"frequency\":\"Month\",\"interval\":1147399422,\"endTime\":\"sjcitdigsxc\",\"startTime\":\"l\",\"timeZone\":\"lkeuac\"},\"cron\":{\"triggerType\":\"Cron\",\"expression\":\"omflrytswfp\",\"endTime\":\"dgycxnmskwhqjjy\",\"startTime\":\"urlpshh\",\"timeZone\":\"pedwqsl\"},\"schedule\":{\"id\":\"mpqvwwsk\",\"provisioningStatus\":\"Completed\",\"status\":\"Disabled\"}},{\"id\":\"wimuvqej\",\"provisioningStatus\":\"Failed\",\"status\":\"Disabled\",\"action\":\"Start\",\"triggerType\":\"Recurrence\",\"recurrence\":{\"triggerType\":\"Recurrence\",\"frequency\":\"Week\",\"interval\":1658057009,\"endTime\":\"uqtljqobbpih\",\"startTime\":\"cecybmrqbrjbbmpx\",\"timeZone\":\"vykfrexcrse\"},\"cron\":{\"triggerType\":\"Cron\",\"expression\":\"jksghudg\",\"endTime\":\"xog\",\"startTime\":\"gsv\",\"timeZone\":\"jkxibda\"},\"schedule\":{\"id\":\"kmdyomkxfbvfbh\",\"provisioningStatus\":\"Completed\",\"status\":\"Disabled\"}}]}")
                .toObject(ComputeSchedules.class);
        Assertions.assertEquals(ScheduleStatus.DISABLED, model.computeStartStop().get(0).status());
        Assertions.assertEquals(ComputePowerAction.START, model.computeStartStop().get(0).action());
        Assertions.assertEquals(TriggerType.CRON, model.computeStartStop().get(0).triggerType());
        Assertions.assertEquals("w", model.computeStartStop().get(0).recurrence().endTime());
        Assertions.assertEquals("jsmwrokc", model.computeStartStop().get(0).recurrence().startTime());
        Assertions.assertEquals("fzzzwyjafitlhg", model.computeStartStop().get(0).recurrence().timeZone());
        Assertions.assertEquals(RecurrenceFrequency.HOUR, model.computeStartStop().get(0).recurrence().frequency());
        Assertions.assertEquals(1941330764, model.computeStartStop().get(0).recurrence().interval());
        Assertions.assertEquals("sgzv", model.computeStartStop().get(0).cron().endTime());
        Assertions.assertEquals("snnjzfpafolpym", model.computeStartStop().get(0).cron().startTime());
        Assertions.assertEquals("mxq", model.computeStartStop().get(0).cron().timeZone());
        Assertions.assertEquals("nuchlgmltxdwhmo", model.computeStartStop().get(0).cron().expression());
        Assertions.assertEquals("gpgdphtvdulaj", model.computeStartStop().get(0).schedule().id());
        Assertions
            .assertEquals(
                ScheduleProvisioningState.PROVISIONING,
                model.computeStartStop().get(0).schedule().provisioningStatus());
        Assertions.assertEquals(ScheduleStatus.ENABLED, model.computeStartStop().get(0).schedule().status());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ComputeSchedules model =
            new ComputeSchedules()
                .withComputeStartStop(
                    Arrays
                        .asList(
                            new ComputeStartStopSchedule()
                                .withStatus(ScheduleStatus.DISABLED)
                                .withAction(ComputePowerAction.START)
                                .withTriggerType(TriggerType.CRON)
                                .withRecurrence(
                                    new RecurrenceTrigger()
                                        .withEndTime("w")
                                        .withStartTime("jsmwrokc")
                                        .withTimeZone("fzzzwyjafitlhg")
                                        .withFrequency(RecurrenceFrequency.HOUR)
                                        .withInterval(1941330764))
                                .withCron(
                                    new CronTrigger()
                                        .withEndTime("sgzv")
                                        .withStartTime("snnjzfpafolpym")
                                        .withTimeZone("mxq")
                                        .withExpression("nuchlgmltxdwhmo"))
                                .withSchedule(
                                    new ScheduleBase()
                                        .withId("gpgdphtvdulaj")
                                        .withProvisioningStatus(ScheduleProvisioningState.PROVISIONING)
                                        .withStatus(ScheduleStatus.ENABLED)),
                            new ComputeStartStopSchedule()
                                .withStatus(ScheduleStatus.DISABLED)
                                .withAction(ComputePowerAction.START)
                                .withTriggerType(TriggerType.CRON)
                                .withRecurrence(
                                    new RecurrenceTrigger()
                                        .withEndTime("q")
                                        .withStartTime("jhmqrhvthla")
                                        .withTimeZone("dcxsmlz")
                                        .withFrequency(RecurrenceFrequency.HOUR)
                                        .withInterval(794571898))
                                .withCron(
                                    new CronTrigger()
                                        .withEndTime("qvlnnpxybafiqgea")
                                        .withStartTime("bgj")
                                        .withTimeZone("glklb")
                                        .withExpression("zdtxetlgyd"))
                                .withSchedule(
                                    new ScheduleBase()
                                        .withId("idwcwvmzegjon")
                                        .withProvisioningStatus(ScheduleProvisioningState.PROVISIONING)
                                        .withStatus(ScheduleStatus.DISABLED)),
                            new ComputeStartStopSchedule()
                                .withStatus(ScheduleStatus.DISABLED)
                                .withAction(ComputePowerAction.STOP)
                                .withTriggerType(TriggerType.CRON)
                                .withRecurrence(
                                    new RecurrenceTrigger()
                                        .withEndTime("sjcitdigsxc")
                                        .withStartTime("l")
                                        .withTimeZone("lkeuac")
                                        .withFrequency(RecurrenceFrequency.MONTH)
                                        .withInterval(1147399422))
                                .withCron(
                                    new CronTrigger()
                                        .withEndTime("dgycxnmskwhqjjy")
                                        .withStartTime("urlpshh")
                                        .withTimeZone("pedwqsl")
                                        .withExpression("omflrytswfp"))
                                .withSchedule(
                                    new ScheduleBase()
                                        .withId("mpqvwwsk")
                                        .withProvisioningStatus(ScheduleProvisioningState.COMPLETED)
                                        .withStatus(ScheduleStatus.DISABLED)),
                            new ComputeStartStopSchedule()
                                .withStatus(ScheduleStatus.DISABLED)
                                .withAction(ComputePowerAction.START)
                                .withTriggerType(TriggerType.RECURRENCE)
                                .withRecurrence(
                                    new RecurrenceTrigger()
                                        .withEndTime("uqtljqobbpih")
                                        .withStartTime("cecybmrqbrjbbmpx")
                                        .withTimeZone("vykfrexcrse")
                                        .withFrequency(RecurrenceFrequency.WEEK)
                                        .withInterval(1658057009))
                                .withCron(
                                    new CronTrigger()
                                        .withEndTime("xog")
                                        .withStartTime("gsv")
                                        .withTimeZone("jkxibda")
                                        .withExpression("jksghudg"))
                                .withSchedule(
                                    new ScheduleBase()
                                        .withId("kmdyomkxfbvfbh")
                                        .withProvisioningStatus(ScheduleProvisioningState.COMPLETED)
                                        .withStatus(ScheduleStatus.DISABLED))));
        model = BinaryData.fromObject(model).toObject(ComputeSchedules.class);
        Assertions.assertEquals(ScheduleStatus.DISABLED, model.computeStartStop().get(0).status());
        Assertions.assertEquals(ComputePowerAction.START, model.computeStartStop().get(0).action());
        Assertions.assertEquals(TriggerType.CRON, model.computeStartStop().get(0).triggerType());
        Assertions.assertEquals("w", model.computeStartStop().get(0).recurrence().endTime());
        Assertions.assertEquals("jsmwrokc", model.computeStartStop().get(0).recurrence().startTime());
        Assertions.assertEquals("fzzzwyjafitlhg", model.computeStartStop().get(0).recurrence().timeZone());
        Assertions.assertEquals(RecurrenceFrequency.HOUR, model.computeStartStop().get(0).recurrence().frequency());
        Assertions.assertEquals(1941330764, model.computeStartStop().get(0).recurrence().interval());
        Assertions.assertEquals("sgzv", model.computeStartStop().get(0).cron().endTime());
        Assertions.assertEquals("snnjzfpafolpym", model.computeStartStop().get(0).cron().startTime());
        Assertions.assertEquals("mxq", model.computeStartStop().get(0).cron().timeZone());
        Assertions.assertEquals("nuchlgmltxdwhmo", model.computeStartStop().get(0).cron().expression());
        Assertions.assertEquals("gpgdphtvdulaj", model.computeStartStop().get(0).schedule().id());
        Assertions
            .assertEquals(
                ScheduleProvisioningState.PROVISIONING,
                model.computeStartStop().get(0).schedule().provisioningStatus());
        Assertions.assertEquals(ScheduleStatus.ENABLED, model.computeStartStop().get(0).schedule().status());
    }
}
