// 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.ComputeStartStopSchedule;
import com.azure.resourcemanager.machinelearning.models.CronTrigger;
import com.azure.resourcemanager.machinelearning.models.RecurrenceFrequency;
import com.azure.resourcemanager.machinelearning.models.RecurrenceSchedule;
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 com.azure.resourcemanager.machinelearning.models.WeekDay;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ComputeStartStopScheduleTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ComputeStartStopSchedule model =
            BinaryData
                .fromString(
                    "{\"id\":\"wpg\",\"provisioningStatus\":\"Failed\",\"status\":\"Enabled\",\"action\":\"Start\",\"triggerType\":\"Recurrence\",\"recurrence\":{\"triggerType\":\"Recurrence\",\"frequency\":\"Day\",\"interval\":926595396,\"schedule\":{\"hours\":[1582308433],\"minutes\":[166613008],\"monthDays\":[587867611,1327364121],\"weekDays\":[\"Thursday\"]},\"endTime\":\"bwsnsqow\",\"startTime\":\"comlikytwvczc\",\"timeZone\":\"k\"},\"cron\":{\"triggerType\":\"Cron\",\"expression\":\"ve\",\"endTime\":\"fdv\",\"startTime\":\"hbwrnfxtgddpqth\",\"timeZone\":\"n\"},\"schedule\":{\"id\":\"oya\",\"provisioningStatus\":\"Provisioning\",\"status\":\"Disabled\"}}")
                .toObject(ComputeStartStopSchedule.class);
        Assertions.assertEquals(ScheduleStatus.ENABLED, model.status());
        Assertions.assertEquals(ComputePowerAction.START, model.action());
        Assertions.assertEquals(TriggerType.RECURRENCE, model.triggerType());
        Assertions.assertEquals("bwsnsqow", model.recurrence().endTime());
        Assertions.assertEquals("comlikytwvczc", model.recurrence().startTime());
        Assertions.assertEquals("k", model.recurrence().timeZone());
        Assertions.assertEquals(RecurrenceFrequency.DAY, model.recurrence().frequency());
        Assertions.assertEquals(926595396, model.recurrence().interval());
        Assertions.assertEquals(1582308433, model.recurrence().schedule().hours().get(0));
        Assertions.assertEquals(166613008, model.recurrence().schedule().minutes().get(0));
        Assertions.assertEquals(587867611, model.recurrence().schedule().monthDays().get(0));
        Assertions.assertEquals(WeekDay.THURSDAY, model.recurrence().schedule().weekDays().get(0));
        Assertions.assertEquals("fdv", model.cron().endTime());
        Assertions.assertEquals("hbwrnfxtgddpqth", model.cron().startTime());
        Assertions.assertEquals("n", model.cron().timeZone());
        Assertions.assertEquals("ve", model.cron().expression());
        Assertions.assertEquals("oya", model.schedule().id());
        Assertions.assertEquals(ScheduleProvisioningState.PROVISIONING, model.schedule().provisioningStatus());
        Assertions.assertEquals(ScheduleStatus.DISABLED, model.schedule().status());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ComputeStartStopSchedule model =
            new ComputeStartStopSchedule()
                .withStatus(ScheduleStatus.ENABLED)
                .withAction(ComputePowerAction.START)
                .withTriggerType(TriggerType.RECURRENCE)
                .withRecurrence(
                    new RecurrenceTrigger()
                        .withEndTime("bwsnsqow")
                        .withStartTime("comlikytwvczc")
                        .withTimeZone("k")
                        .withFrequency(RecurrenceFrequency.DAY)
                        .withInterval(926595396)
                        .withSchedule(
                            new RecurrenceSchedule()
                                .withHours(Arrays.asList(1582308433))
                                .withMinutes(Arrays.asList(166613008))
                                .withMonthDays(Arrays.asList(587867611, 1327364121))
                                .withWeekDays(Arrays.asList(WeekDay.THURSDAY))))
                .withCron(
                    new CronTrigger()
                        .withEndTime("fdv")
                        .withStartTime("hbwrnfxtgddpqth")
                        .withTimeZone("n")
                        .withExpression("ve"))
                .withSchedule(
                    new ScheduleBase()
                        .withId("oya")
                        .withProvisioningStatus(ScheduleProvisioningState.PROVISIONING)
                        .withStatus(ScheduleStatus.DISABLED));
        model = BinaryData.fromObject(model).toObject(ComputeStartStopSchedule.class);
        Assertions.assertEquals(ScheduleStatus.ENABLED, model.status());
        Assertions.assertEquals(ComputePowerAction.START, model.action());
        Assertions.assertEquals(TriggerType.RECURRENCE, model.triggerType());
        Assertions.assertEquals("bwsnsqow", model.recurrence().endTime());
        Assertions.assertEquals("comlikytwvczc", model.recurrence().startTime());
        Assertions.assertEquals("k", model.recurrence().timeZone());
        Assertions.assertEquals(RecurrenceFrequency.DAY, model.recurrence().frequency());
        Assertions.assertEquals(926595396, model.recurrence().interval());
        Assertions.assertEquals(1582308433, model.recurrence().schedule().hours().get(0));
        Assertions.assertEquals(166613008, model.recurrence().schedule().minutes().get(0));
        Assertions.assertEquals(587867611, model.recurrence().schedule().monthDays().get(0));
        Assertions.assertEquals(WeekDay.THURSDAY, model.recurrence().schedule().weekDays().get(0));
        Assertions.assertEquals("fdv", model.cron().endTime());
        Assertions.assertEquals("hbwrnfxtgddpqth", model.cron().startTime());
        Assertions.assertEquals("n", model.cron().timeZone());
        Assertions.assertEquals("ve", model.cron().expression());
        Assertions.assertEquals("oya", model.schedule().id());
        Assertions.assertEquals(ScheduleProvisioningState.PROVISIONING, model.schedule().provisioningStatus());
        Assertions.assertEquals(ScheduleStatus.DISABLED, model.schedule().status());
    }
}
