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

package com.azure.resourcemanager.frontdoor.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.frontdoor.fluent.models.TimeseriesProperties;
import com.azure.resourcemanager.frontdoor.models.AggregationInterval;
import com.azure.resourcemanager.frontdoor.models.TimeseriesDataPoint;
import com.azure.resourcemanager.frontdoor.models.TimeseriesType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class TimeseriesPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TimeseriesProperties model =
            BinaryData
                .fromString(
                    "{\"endpoint\":\"ugzxnf\",\"startDateTimeUTC\":\"zpxdt\",\"endDateTimeUTC\":\"dm\",\"aggregationInterval\":\"Hourly\",\"timeseriesType\":\"LatencyP75\",\"country\":\"uenvrkp\",\"timeseriesData\":[{\"dateTimeUTC\":\"ibreb\",\"value\":90.0324},{\"dateTimeUTC\":\"sj\",\"value\":30.97995},{\"dateTimeUTC\":\"tnqttezlwfffiak\",\"value\":43.313293},{\"dateTimeUTC\":\"qmt\",\"value\":18.969006}]}")
                .toObject(TimeseriesProperties.class);
        Assertions.assertEquals("ugzxnf", model.endpoint());
        Assertions.assertEquals("zpxdt", model.startDateTimeUtc());
        Assertions.assertEquals("dm", model.endDateTimeUtc());
        Assertions.assertEquals(AggregationInterval.HOURLY, model.aggregationInterval());
        Assertions.assertEquals(TimeseriesType.LATENCY_P75, model.timeseriesType());
        Assertions.assertEquals("uenvrkp", model.country());
        Assertions.assertEquals("ibreb", model.timeseriesData().get(0).dateTimeUtc());
        Assertions.assertEquals(90.0324F, model.timeseriesData().get(0).value());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TimeseriesProperties model =
            new TimeseriesProperties()
                .withEndpoint("ugzxnf")
                .withStartDateTimeUtc("zpxdt")
                .withEndDateTimeUtc("dm")
                .withAggregationInterval(AggregationInterval.HOURLY)
                .withTimeseriesType(TimeseriesType.LATENCY_P75)
                .withCountry("uenvrkp")
                .withTimeseriesData(
                    Arrays
                        .asList(
                            new TimeseriesDataPoint().withDateTimeUtc("ibreb").withValue(90.0324F),
                            new TimeseriesDataPoint().withDateTimeUtc("sj").withValue(30.97995F),
                            new TimeseriesDataPoint().withDateTimeUtc("tnqttezlwfffiak").withValue(43.313293F),
                            new TimeseriesDataPoint().withDateTimeUtc("qmt").withValue(18.969006F)));
        model = BinaryData.fromObject(model).toObject(TimeseriesProperties.class);
        Assertions.assertEquals("ugzxnf", model.endpoint());
        Assertions.assertEquals("zpxdt", model.startDateTimeUtc());
        Assertions.assertEquals("dm", model.endDateTimeUtc());
        Assertions.assertEquals(AggregationInterval.HOURLY, model.aggregationInterval());
        Assertions.assertEquals(TimeseriesType.LATENCY_P75, model.timeseriesType());
        Assertions.assertEquals("uenvrkp", model.country());
        Assertions.assertEquals("ibreb", model.timeseriesData().get(0).dateTimeUtc());
        Assertions.assertEquals(90.0324F, model.timeseriesData().get(0).value());
    }
}
