// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.security.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.security.models.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem;
import com.azure.resourcemanager.security.models.IoTSeverityMetrics;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItemTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem model =
            BinaryData
                .fromString(
                    "{\"date\":\"2021-08-28T04:10:12Z\",\"devicesMetrics\":{\"high\":6531016586304771464,\"medium\":6112562014909407139,\"low\":4716171323603349027}}")
                .toObject(IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-28T04:10:12Z"), model.date());
        Assertions.assertEquals(6531016586304771464L, model.devicesMetrics().high());
        Assertions.assertEquals(6112562014909407139L, model.devicesMetrics().medium());
        Assertions.assertEquals(4716171323603349027L, model.devicesMetrics().low());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem model =
            new IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem()
                .withDate(OffsetDateTime.parse("2021-08-28T04:10:12Z"))
                .withDevicesMetrics(
                    new IoTSeverityMetrics()
                        .withHigh(6531016586304771464L)
                        .withMedium(6112562014909407139L)
                        .withLow(4716171323603349027L));
        model =
            BinaryData.fromObject(model).toObject(IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-28T04:10:12Z"), model.date());
        Assertions.assertEquals(6531016586304771464L, model.devicesMetrics().high());
        Assertions.assertEquals(6112562014909407139L, model.devicesMetrics().medium());
        Assertions.assertEquals(4716171323603349027L, model.devicesMetrics().low());
    }
}
