// 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.CostThresholdProperties;
import com.azure.resourcemanager.devtestlabs.models.CostThresholdStatus;
import com.azure.resourcemanager.devtestlabs.models.PercentageCostThresholdProperties;
import com.azure.resourcemanager.devtestlabs.models.ReportingCycleType;
import com.azure.resourcemanager.devtestlabs.models.TargetCostProperties;
import com.azure.resourcemanager.devtestlabs.models.TargetCostStatus;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class TargetCostPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TargetCostProperties model =
            BinaryData
                .fromString(
                    "{\"status\":\"Disabled\",\"target\":1382848835,\"costThresholds\":[{\"thresholdId\":\"rgly\",\"percentageThreshold\":{\"thresholdValue\":34.048141840374136},\"displayOnChart\":\"Disabled\",\"sendNotificationWhenExceeded\":\"Disabled\",\"notificationSent\":\"ejrjxgciqibrho\"},{\"thresholdId\":\"sdqrhzoymibmrq\",\"percentageThreshold\":{\"thresholdValue\":81.89814432581672},\"displayOnChart\":\"Enabled\",\"sendNotificationWhenExceeded\":\"Disabled\",\"notificationSent\":\"zdtmhrkwofy\"},{\"thresholdId\":\"oqac\",\"percentageThreshold\":{\"thresholdValue\":57.89401262251441},\"displayOnChart\":\"Enabled\",\"sendNotificationWhenExceeded\":\"Disabled\",\"notificationSent\":\"bwoenwashrt\"}],\"cycleStartDateTime\":\"2021-03-25T05:20:51Z\",\"cycleEndDateTime\":\"2021-10-02T00:32Z\",\"cycleType\":\"Custom\"}")
                .toObject(TargetCostProperties.class);
        Assertions.assertEquals(TargetCostStatus.DISABLED, model.status());
        Assertions.assertEquals(1382848835, model.target());
        Assertions.assertEquals("rgly", model.costThresholds().get(0).thresholdId());
        Assertions
            .assertEquals(34.048141840374136D, model.costThresholds().get(0).percentageThreshold().thresholdValue());
        Assertions.assertEquals(CostThresholdStatus.DISABLED, model.costThresholds().get(0).displayOnChart());
        Assertions
            .assertEquals(CostThresholdStatus.DISABLED, model.costThresholds().get(0).sendNotificationWhenExceeded());
        Assertions.assertEquals("ejrjxgciqibrho", model.costThresholds().get(0).notificationSent());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-25T05:20:51Z"), model.cycleStartDateTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-02T00:32Z"), model.cycleEndDateTime());
        Assertions.assertEquals(ReportingCycleType.CUSTOM, model.cycleType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TargetCostProperties model =
            new TargetCostProperties()
                .withStatus(TargetCostStatus.DISABLED)
                .withTarget(1382848835)
                .withCostThresholds(
                    Arrays
                        .asList(
                            new CostThresholdProperties()
                                .withThresholdId("rgly")
                                .withPercentageThreshold(
                                    new PercentageCostThresholdProperties().withThresholdValue(34.048141840374136D))
                                .withDisplayOnChart(CostThresholdStatus.DISABLED)
                                .withSendNotificationWhenExceeded(CostThresholdStatus.DISABLED)
                                .withNotificationSent("ejrjxgciqibrho"),
                            new CostThresholdProperties()
                                .withThresholdId("sdqrhzoymibmrq")
                                .withPercentageThreshold(
                                    new PercentageCostThresholdProperties().withThresholdValue(81.89814432581672D))
                                .withDisplayOnChart(CostThresholdStatus.ENABLED)
                                .withSendNotificationWhenExceeded(CostThresholdStatus.DISABLED)
                                .withNotificationSent("zdtmhrkwofy"),
                            new CostThresholdProperties()
                                .withThresholdId("oqac")
                                .withPercentageThreshold(
                                    new PercentageCostThresholdProperties().withThresholdValue(57.89401262251441D))
                                .withDisplayOnChart(CostThresholdStatus.ENABLED)
                                .withSendNotificationWhenExceeded(CostThresholdStatus.DISABLED)
                                .withNotificationSent("bwoenwashrt")))
                .withCycleStartDateTime(OffsetDateTime.parse("2021-03-25T05:20:51Z"))
                .withCycleEndDateTime(OffsetDateTime.parse("2021-10-02T00:32Z"))
                .withCycleType(ReportingCycleType.CUSTOM);
        model = BinaryData.fromObject(model).toObject(TargetCostProperties.class);
        Assertions.assertEquals(TargetCostStatus.DISABLED, model.status());
        Assertions.assertEquals(1382848835, model.target());
        Assertions.assertEquals("rgly", model.costThresholds().get(0).thresholdId());
        Assertions
            .assertEquals(34.048141840374136D, model.costThresholds().get(0).percentageThreshold().thresholdValue());
        Assertions.assertEquals(CostThresholdStatus.DISABLED, model.costThresholds().get(0).displayOnChart());
        Assertions
            .assertEquals(CostThresholdStatus.DISABLED, model.costThresholds().get(0).sendNotificationWhenExceeded());
        Assertions.assertEquals("ejrjxgciqibrho", model.costThresholds().get(0).notificationSent());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-25T05:20:51Z"), model.cycleStartDateTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-02T00:32Z"), model.cycleEndDateTime());
        Assertions.assertEquals(ReportingCycleType.CUSTOM, model.cycleType());
    }
}
